conf: cleanup macros get{g,u}name

parent 00d6cfe2
...@@ -4597,10 +4597,9 @@ on_error: ...@@ -4597,10 +4597,9 @@ on_error:
/* not thread-safe, do not use from api without first forking */ /* not thread-safe, do not use from api without first forking */
static char *getuname(void) static char *getuname(void)
{ {
__do_free char *buf = NULL;
struct passwd pwent; struct passwd pwent;
struct passwd *pwentp = NULL; struct passwd *pwentp = NULL;
char *buf;
char *username;
size_t bufsize; size_t bufsize;
int ret; int ret;
...@@ -4618,23 +4617,18 @@ static char *getuname(void) ...@@ -4618,23 +4617,18 @@ static char *getuname(void)
WARN("Could not find matched password record."); WARN("Could not find matched password record.");
ERROR("Failed to get password record - %u", geteuid()); ERROR("Failed to get password record - %u", geteuid());
free(buf);
return NULL; return NULL;
} }
username = strdup(pwent.pw_name); return strdup(pwent.pw_name);
free(buf);
return username;
} }
/* not thread-safe, do not use from api without first forking */ /* not thread-safe, do not use from api without first forking */
static char *getgname(void) static char *getgname(void)
{ {
__do_free char *buf = NULL;
struct group grent; struct group grent;
struct group *grentp = NULL; struct group *grentp = NULL;
char *buf;
char *grname;
size_t bufsize; size_t bufsize;
int ret; int ret;
...@@ -4652,14 +4646,10 @@ static char *getgname(void) ...@@ -4652,14 +4646,10 @@ static char *getgname(void)
WARN("Could not find matched group record"); WARN("Could not find matched group record");
ERROR("Failed to get group record - %u", getegid()); ERROR("Failed to get group record - %u", getegid());
free(buf);
return NULL; return NULL;
} }
grname = strdup(grent.gr_name); return strdup(grent.gr_name);
free(buf);
return grname;
} }
/* not thread-safe, do not use from api without first forking */ /* not thread-safe, do not use from api without first forking */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment