Skip to content

Commit

Permalink
use snprintf instead of sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
vaishalikumanan committed Aug 9, 2021
1 parent 53565c7 commit 5a3ad2f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ static bool spawn_process(struct pss_tty *pss, uint16_t columns, uint16_t rows)
}
else if (server->arg_file != NULL) {
int fd = -1;
char *filePath = xmalloc(strlen(server->arg_file) + 7);
sprintf(filePath, "%sXXXXXX", server->arg_file);
// mkstemp requires the file path to have suffix XXXXXX (len 7)
int file_path_len = strlen(server->arg_file) + 7;
char *filePath = xmalloc(file_path_len);
snprintf(filePath, file_path_len, "%sXXXXXX", server->arg_file);

if ((fd = mkstemp(filePath)) == -1) {
lwsl_err("Creation of temp file failed with error: %d (%s)\n", errno, strerror(errno));
Expand Down

0 comments on commit 5a3ad2f

Please sign in to comment.