[hackers] [ubase] Use a compound literal instead of malloc() in su(1) || sin
commit f7fdd5897296a7b9389b6c292e278d842a7a1baf
Author: sin <sin_AT_2f30.org>
Date: Fri Oct 18 10:08:10 2013 +0100
Use a compound literal instead of malloc() in su(1)
diff --git a/su.c b/su.c
index d2e28e8..273728a 100644
--- a/su.c
+++ b/su.c
_AT_@ -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;
_AT_@ -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;
Received on Fri Oct 18 2013 - 11:10:44 CEST
This archive was generated by hypermail 2.3.0
: Fri Oct 18 2013 - 11:12:32 CEST