ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit f7fdd5897296a7b9389b6c292e278d842a7a1baf
parent dac38406c2c10cd05dab321f17deb4df48f1aea8
Author: sin <sin@2f30.org>
Date:   Fri Oct 18 10:08:10 +0100

Use a compound literal instead of malloc() in su(1)

Diffstat:
su.c | 8++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/su.c b/su.c @@ -20,7 +20,7 @@ int main(int argc, char **argv) { char *usr, *pass, *cryptpass; - char **newargv; + char * const *newargv; struct spwd *spw; struct passwd *pw; uid_t uid; @@ -83,11 +83,7 @@ main(int argc, char **argv) if (setuid(pw->pw_uid) < 0) eprintf("setuid:"); - newargv = malloc(2 * sizeof(char *)); - if (!newargv) - eprintf("malloc:"); - newargv[0] = pw->pw_shell; - newargv[1] = NULL; + newargv = (char *const[]){pw->pw_shell, NULL}; setenv("HOME", pw->pw_dir, 1); execve(pw->pw_shell, newargv, environ); return (errno == ENOENT) ? 127 : 126;