Detect if argv[1] is "" and avoid calling malloc(0). Prior to this commit,

running 'tar ""' would print 'No memory' instead of the correct error
message, 'Must specify one of -c, -r, -t, -u, -x' if malloc is set to
System V mode (malloc(0) == NULL).
This commit is contained in:
cperciva 2008-05-19 18:38:01 +00:00
parent ee71b68b4b
commit a806c30ec3

View File

@ -726,8 +726,8 @@ rewrite_argv(struct bsdtar *bsdtar, int *argc, char **src_argv,
const char *p;
char *src, *dest;
if (src_argv[0] == NULL ||
src_argv[1] == NULL || src_argv[1][0] == '-')
if (src_argv[0] == NULL || src_argv[1] == NULL ||
src_argv[1][0] == '-' || src_argv[1][0] == '\0')
return (src_argv);
*argc += strlen(src_argv[1]) - 1;