diff options
-rw-r--r-- | editors/sed.c | 5 | ||||
-rw-r--r-- | sed.c | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/editors/sed.c b/editors/sed.c index 47fb63712..95be01822 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) | |||
388 | /* the first non-whitespace we get is a filename. the filename ends when we | 388 | /* the first non-whitespace we get is a filename. the filename ends when we |
389 | * hit a normal sed command terminator or end of string */ | 389 | * hit a normal sed command terminator or end of string */ |
390 | filenamelen = strcspn(&filecmdstr[idx], "; \n\r\t\v\0"); | 390 | filenamelen = strcspn(&filecmdstr[idx], "; \n\r\t\v\0"); |
391 | sed_cmd->filename = xmalloc(sizeof(char) * filenamelen + 1); | 391 | sed_cmd->filename = xmalloc(filenamelen + 1); |
392 | strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen); | 392 | safe_strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen + 1); |
393 | sed_cmd->filename[filenamelen] = 0; | ||
394 | 393 | ||
395 | return idx + filenamelen; | 394 | return idx + filenamelen; |
396 | } | 395 | } |
@@ -388,9 +388,8 @@ static int parse_file_cmd(struct sed_cmd *sed_cmd, const char *filecmdstr) | |||
388 | /* the first non-whitespace we get is a filename. the filename ends when we | 388 | /* the first non-whitespace we get is a filename. the filename ends when we |
389 | * hit a normal sed command terminator or end of string */ | 389 | * hit a normal sed command terminator or end of string */ |
390 | filenamelen = strcspn(&filecmdstr[idx], "; \n\r\t\v\0"); | 390 | filenamelen = strcspn(&filecmdstr[idx], "; \n\r\t\v\0"); |
391 | sed_cmd->filename = xmalloc(sizeof(char) * filenamelen + 1); | 391 | sed_cmd->filename = xmalloc(filenamelen + 1); |
392 | strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen); | 392 | safe_strncpy(sed_cmd->filename, &filecmdstr[idx], filenamelen + 1); |
393 | sed_cmd->filename[filenamelen] = 0; | ||
394 | 393 | ||
395 | return idx + filenamelen; | 394 | return idx + filenamelen; |
396 | } | 395 | } |