← Commit list

666c40c9f

Denis Vlasenko
Denis Vlasenko
2007-03-31
FAILED Duration: 16s

Subject

unzip: fix xstrndup bug (xstrndup(s,n) can allocate less than n bytes!)

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

archival/unzip.c+3 -2
@@ -134,7 +134,8 @@ int unzip_main(int argc, char **argv)
break;
case 1 : /* The zip file */
- src_fn = xstrndup(optarg, strlen(optarg)+4);
+ src_fn = xmalloc(strlen(optarg)+4);
+ strcpy(src_fn, optarg);
opt_range++;
break;
@@ -195,7 +196,7 @@ int unzip_main(int argc, char **argv)
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
- src_fn[orig_src_fn_len] = 0;
+ src_fn[orig_src_fn_len] = '\0';
bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
}
}