X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Fuudecode.c;h=a4059ddfe9b78c34221a902fe9d68994a0dfceb2;hb=4bcdd7214217bfdaa2c4015425d439686d5b8b0b;hp=c0e8cea8cb5ed571baaac30c1bbbf68c9ea3d1a7;hpb=67991cf824f8df27e74c92d754fb507681c69ce6;p=oweals%2Fbusybox.git diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index c0e8cea8c..a4059ddfe 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c @@ -22,13 +22,13 @@ */ -#include "busybox.h" #include #include #include #include #include +#include "busybox.h" #include "pwd_grp/pwd.h" #include "pwd_grp/grp.h" @@ -201,12 +201,13 @@ static int decode (const char *inname, const char *forced_outname) { struct passwd *pw; - register int n; register char *p; - int mode, n1; + int mode; char buf[2 * BUFSIZ]; char *outname; int do_base64 = 0; + int res; + int dofre; /* Search for header line. */ @@ -226,6 +227,7 @@ static int decode (const char *inname, } /* If the output file name is given on the command line this rules. */ + dofre = FALSE; if (forced_outname != NULL) outname = (char *) forced_outname; else { @@ -246,12 +248,8 @@ static int decode (const char *inname, error_msg("%s: No user `%s'", inname, buf + 1); return FALSE; } - n = strlen (pw->pw_dir); - n1 = strlen (p); - outname = (char *) alloca ((size_t) (n + n1 + 2)); - memcpy (outname + n + 1, p, (size_t) (n1 + 1)); - memcpy (outname, pw->pw_dir, (size_t) n); - outname[n] = '/'; + outname = concat_path_file(pw->pw_dir, p); + dofre = TRUE; } } @@ -261,6 +259,8 @@ static int decode (const char *inname, || chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO)) )) { perror_msg("%s", outname); /* */ + if (dofre) + free(outname); return FALSE; } @@ -269,9 +269,12 @@ static int decode (const char *inname, /* For each input line: */ if (do_base64) - return read_base64 (inname); + res = read_base64 (inname); else - return read_stduu (inname); + res = read_stduu (inname); + if (dofre) + free(outname); + return res; } int uudecode_main (int argc,