summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblueness <basile@opensource.dyc.edu>2013-10-26 08:34:14 -0700
committerblueness <basile@opensource.dyc.edu>2013-10-26 08:34:14 -0700
commitfa832a2f56f30555f56637a6f2247ce18e4a54f9 (patch)
treee4e8ae698bacca5660119fa3b0e42744f6ba9a78
parent69d8113995f6ec222798bc3164d2f1987cf4f5e6 (diff)
parentb49b09e046df217335dca68bc787b6b9d10bce44 (diff)
Merge pull request #81 from michaelforney/default-buflen
Handle -1 return from sysconf(_SC_GET{PW,GR}_R_SIZE_MAX)
-rw-r--r--src/libudev/libudev-util.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c
index 522a984c3b..ae5e285ec0 100644
--- a/src/libudev/libudev-util.c
+++ b/src/libudev/libudev-util.c
@@ -84,8 +84,11 @@ uid_t util_lookup_user(struct udev *udev, const char *user)
struct passwd *pw;
uid_t uid;
size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
- char *buf = alloca(buflen);
+ char *buf;
+ if (buflen == -1)
+ buflen = 1024;
+ buf = alloca(buflen);
if (streq(user, "root"))
return 0;
uid = strtoul(user, &endptr, 10);
@@ -108,9 +111,11 @@ gid_t util_lookup_group(struct udev *udev, const char *group)
struct group grbuf;
struct group *gr;
gid_t gid = 0;
- size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
+ size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
char *buf = NULL;
+ if (buflen == -1)
+ buflen = 1024;
if (streq(group, "root"))
return 0;
gid = strtoul(group, &endptr, 10);