Skip to content

Commit 8c92b5f

Browse files
committed
TSRM: change uses of sprintf into snprintf
1 parent 3b83d7e commit 8c92b5f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

TSRM/tsrm_win32.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,13 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
477477
return NULL;
478478
}
479479

480-
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /s /c ")+2);
480+
size_t cmd_buffer_size = strlen(command) + strlen(TWG(comspec)) + sizeof(" /s /c ") + 2;
481+
cmd = malloc(cmd_buffer_size);
481482
if (!cmd) {
482483
return NULL;
483484
}
484485

485-
sprintf(cmd, "%s /s /c \"%s\"", TWG(comspec), command);
486+
snprintf(cmd, cmd_buffer_size, "%s /s /c \"%s\"", TWG(comspec), command);
486487
cmdw = php_win32_cp_any_to_w(cmd);
487488
if (!cmdw) {
488489
free(cmd);

0 commit comments

Comments
 (0)