*/
-#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
+#include "busybox.h"
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
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. */
}
/* If the output file name is given on the command line this rules. */
+ dofre = FALSE;
if (forced_outname != NULL)
outname = (char *) forced_outname;
else {
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;
}
}
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
perror_msg("%s", outname); /* */
+ if (dofre)
+ free(outname);
return FALSE;
}
/* 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,