summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai2001-05-27 14:11:52 +0000
committerMatt Kraai2001-05-27 14:11:52 +0000
commit6e9e136fcbd1883cf8a29d87b3825398587a3860 (patch)
tree7a46a06c0f29438cd2ad867e5b8de07afe92b88a
parent4f6aea807b0cd411cbc6f9d3b79e8583d6bd532b (diff)
downloadbusybox-6e9e136fcbd1883cf8a29d87b3825398587a3860.zip
busybox-6e9e136fcbd1883cf8a29d87b3825398587a3860.tar.gz
Use safe_strncpy.
-rw-r--r--editors/sed.c5
-rw-r--r--sed.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 47fb637..95be018 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -388,9 +388,8 @@ static int parse_file_cmd(struct sed_cmd *sed_cmd, const char *filecmdstr)
/* the first non-whitespace we get is a filename. the filename ends when we
* hit a normal sed command terminator or end of string */
filenamelen = strcspn(&filecmdstr[idx], "; \n\r\t\v\0");
- sed_cmd->filename = xmalloc(sizeof(char) * filenamelen + 1);
- strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen);
- sed_cmd->filename[filenamelen] = 0;
+ sed_cmd->filename = xmalloc(filenamelen + 1);
+ safe_strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen + 1);
return idx + filenamelen;
}
diff --git a/sed.c b/sed.c
index 47fb637..95be018 100644
--- a/sed.c
+++ b/sed.c
@@ -388,9 +388,8 @@ static int parse_file_cmd(struct sed_cmd *sed_cmd, const char *filecmdstr)
/* the first non-whitespace we get is a filename. the filename ends when we
* hit a normal sed command terminator or end of string */
filenamelen = strcspn(&filecmdstr[idx], "; \n\r\t\v\0");
- sed_cmd->filename = xmalloc(sizeof(char) * filenamelen + 1);
- strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen);
- sed_cmd->filename[filenamelen] = 0;
+ sed_cmd->filename = xmalloc(filenamelen + 1);
+ safe_strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen + 1);
return idx + filenamelen;
}