svn commit: trunk/busybox/archival

vda at busybox.net vda at busybox.net
Sat Mar 31 10:17:27 UTC 2007


Author: vda
Date: 2007-03-31 03:17:24 -0700 (Sat, 31 Mar 2007)
New Revision: 18285

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


Modified:
   trunk/busybox/archival/unzip.c


Changeset:
Modified: trunk/busybox/archival/unzip.c
===================================================================
--- trunk/busybox/archival/unzip.c	2007-03-31 03:32:05 UTC (rev 18284)
+++ trunk/busybox/archival/unzip.c	2007-03-31 10:17:24 UTC (rev 18285)
@@ -134,7 +134,8 @@
 				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 @@
 			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);
 		}
 	}




More information about the busybox-cvs mailing list