summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-31 10:17:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-31 10:17:24 +0000
commit666c40c9fce062f7466f424176ef2d0b8f581b38 (patch)
treea5f1c60bc6d1666086fd23df2edb2dd2935281ab
parent7b881c716892bfe2fc0edecf2887e0540b25835f (diff)
downloadbusybox-w32-666c40c9fce062f7466f424176ef2d0b8f581b38.tar.gz
busybox-w32-666c40c9fce062f7466f424176ef2d0b8f581b38.tar.bz2
busybox-w32-666c40c9fce062f7466f424176ef2d0b8f581b38.zip
unzip: fix xstrndup bug (xstrndup(s,n) can allocate less than n bytes!)
-rw-r--r--archival/unzip.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index 5e631705c..8a9034fc3 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -134,7 +134,8 @@ int unzip_main(int argc, char **argv)
134 break; 134 break;
135 135
136 case 1 : /* The zip file */ 136 case 1 : /* The zip file */
137 src_fn = xstrndup(optarg, strlen(optarg)+4); 137 src_fn = xmalloc(strlen(optarg)+4);
138 strcpy(src_fn, optarg);
138 opt_range++; 139 opt_range++;
139 break; 140 break;
140 141
@@ -195,7 +196,7 @@ int unzip_main(int argc, char **argv)
195 src_fd = open(src_fn, O_RDONLY); 196 src_fd = open(src_fn, O_RDONLY);
196 } 197 }
197 if (src_fd == -1) { 198 if (src_fd == -1) {
198 src_fn[orig_src_fn_len] = 0; 199 src_fn[orig_src_fn_len] = '\0';
199 bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn); 200 bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
200 } 201 }
201 } 202 }