From: <ta...@us...> - 2007-10-05 06:23:31
|
Revision: 3838 http://gfarm.svn.sourceforge.net/gfarm/?rev=3838&view=rev Author: tatebe Date: 2007-10-04 23:23:34 -0700 (Thu, 04 Oct 2007) Log Message: ----------- fix an error check of getpwnam_r Modified Paths: -------------- gfarm/branches/gfarm_v2/lib/libgfarm/gfarm/auth_server.c Modified: gfarm/branches/gfarm_v2/lib/libgfarm/gfarm/auth_server.c =================================================================== --- gfarm/branches/gfarm_v2/lib/libgfarm/gfarm/auth_server.c 2007-10-05 06:21:19 UTC (rev 3837) +++ gfarm/branches/gfarm_v2/lib/libgfarm/gfarm/auth_server.c 2007-10-05 06:23:34 UTC (rev 3838) @@ -245,7 +245,7 @@ int eof; enum gfarm_auth_id_type peer_type; struct passwd pwbuf, *pwd; - static int bufsize = 0; + static int bufsz = 0; # define BUFSIZE_MAX 2048 e = gfp_xdr_recv(conn, 0, &eof, "s", &global_username); @@ -281,12 +281,12 @@ local_username = NULL; pwd = NULL; } else { - if (bufsize == 0) { - bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); - if (bufsize == -1) - bufsize = BUFSIZE_MAX; + if (bufsz == 0) { + bufsz = sysconf(_SC_GETPW_R_SIZE_MAX); + if (bufsz == -1) + bufsz = BUFSIZE_MAX; } - buf = malloc(bufsize); + buf = malloc(bufsz); if (buf == NULL) { e = GFARM_ERR_NO_MEMORY; gflog_error("(%s@%s) %s: authorize_sharedsecret: %s", @@ -296,8 +296,7 @@ free(global_username); return (e); } - if (getpwnam_r(local_username, &pwbuf, buf, bufsize, &pwd) - == -1 || pwd == NULL) + if (getpwnam_r(local_username, &pwbuf, buf, bufsz, &pwd) != 0) gflog_error("(%s@%s) %s: authorize_sharedsecret: " "local account doesn't exist", global_username, hostname, local_username); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |