aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2000-09-19 06:46:44 +0000
committerMatt Kraai <kraai@debian.org>2000-09-19 06:46:44 +0000
commit0b2da467a8e9cc34c267ac8c38fd69b267dde986 (patch)
tree5f946812074e04018571f7f3be264e93b387a872
parent721119e1db5fdf4de940d777e411b1112116b500 (diff)
downloadbusybox-0b2da467a8e9cc34c267ac8c38fd69b267dde986.tar.gz
Avoid segfaults by not using snprintf to copy strings.
-rw-r--r--lash.c3
-rw-r--r--sh.c3
-rw-r--r--shell/lash.c3
3 files changed, 6 insertions, 3 deletions
diff --git a/lash.c b/lash.c
index a2969082f..cbaf16ef8 100644
--- a/lash.c
+++ b/lash.c
@@ -1023,7 +1023,8 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
/* Make some space to hold just the backticked command */
charptr1 = charptr2 = xmalloc(1+ptr-src);
- snprintf(charptr1, 1+ptr-src, src);
+ memcpy(charptr1, src, ptr-src);
+ charptr1[ptr-src] = '\0';
newJob = xmalloc(sizeof(struct job));
/* Now parse and run the backticked command */
if (!parseCommand(&charptr1, newJob, &njobList, inBg)
diff --git a/sh.c b/sh.c
index a2969082f..cbaf16ef8 100644
--- a/sh.c
+++ b/sh.c
@@ -1023,7 +1023,8 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
/* Make some space to hold just the backticked command */
charptr1 = charptr2 = xmalloc(1+ptr-src);
- snprintf(charptr1, 1+ptr-src, src);
+ memcpy(charptr1, src, ptr-src);
+ charptr1[ptr-src] = '\0';
newJob = xmalloc(sizeof(struct job));
/* Now parse and run the backticked command */
if (!parseCommand(&charptr1, newJob, &njobList, inBg)
diff --git a/shell/lash.c b/shell/lash.c
index a2969082f..cbaf16ef8 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -1023,7 +1023,8 @@ static int parseCommand(char **commandPtr, struct job *job, struct jobSet *jobLi
/* Make some space to hold just the backticked command */
charptr1 = charptr2 = xmalloc(1+ptr-src);
- snprintf(charptr1, 1+ptr-src, src);
+ memcpy(charptr1, src, ptr-src);
+ charptr1[ptr-src] = '\0';
newJob = xmalloc(sizeof(struct job));
/* Now parse and run the backticked command */
if (!parseCommand(&charptr1, newJob, &njobList, inBg)