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:
parent
ee71b68b4b
commit
a806c30ec3
@ -726,8 +726,8 @@ rewrite_argv(struct bsdtar *bsdtar, int *argc, char **src_argv,
|
|||||||
const char *p;
|
const char *p;
|
||||||
char *src, *dest;
|
char *src, *dest;
|
||||||
|
|
||||||
if (src_argv[0] == NULL ||
|
if (src_argv[0] == NULL || src_argv[1] == NULL ||
|
||||||
src_argv[1] == NULL || src_argv[1][0] == '-')
|
src_argv[1][0] == '-' || src_argv[1][0] == '\0')
|
||||||
return (src_argv);
|
return (src_argv);
|
||||||
|
|
||||||
*argc += strlen(src_argv[1]) - 1;
|
*argc += strlen(src_argv[1]) - 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user