diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2020-10-10 00:01:46 -0400 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2020-10-11 09:59:37 -0400 |
commit | d25b9c0f373a169709ec1a2c3a53ee807a2bb083 (patch) | |
tree | 42b63f9c8fd2b714f04d69c96743a76d703ad9fe /src/io.c | |
parent | 5f47194b3b5fc16b3fbda04a8d31f0a1c0713330 (diff) | |
download | calcurse-d25b9c0f373a169709ec1a2c3a53ee807a2bb083.tar.gz calcurse-d25b9c0f373a169709ec1a2c3a53ee807a2bb083.zip |
Use dynamically allocated string in struct io_file
Avoid using fixed-size buffers and strncpy().
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1396,7 +1396,7 @@ struct io_file *io_log_init(void) ERROR_MSG(_("Warning: could not create temporary log file, Aborting...")); goto error; } - strncpy(log->name, logname, sizeof(log->name)); + log->name = mem_strdup(logname); log->fd = fopen(log->name, "w"); if (log->fd == NULL) { ERROR_MSG(_("Warning: could not open temporary log file, Aborting...")); @@ -1446,6 +1446,7 @@ void io_log_free(struct io_file *log) EXIT_IF(unlink(log->name) != 0, _("Warning: could not erase temporary log file %s, Aborting..."), log->name); + mem_free(log->name); mem_free(log); } |