From: darcagn <da...@us...> - 2024-05-23 21:18:40
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b0662100c30161bb25c9af862b5b774e6743c981 (commit) from d5553ac464fdd0057240f608a8f26d266c2c091a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b0662100c30161bb25c9af862b5b774e6743c981 Author: Donald Haase <qu...@ya...> Date: Thu May 23 17:17:58 2024 -0400 Cleaning up filename function to simplify and correct buffer overflow (#590) Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: utils/vqenc/vqenc.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/utils/vqenc/vqenc.c b/utils/vqenc/vqenc.c index d8685d04..f88933c0 100644 --- a/utils/vqenc/vqenc.c +++ b/utils/vqenc/vqenc.c @@ -684,30 +684,21 @@ static void place_quads(context_t *cb, mipmap_t *m) { static const char *figure_outfilename(const char *f, const char *newext) { - char *newname; char *ext; + size_t namelen; + char *newname; ext = strrchr(f, '.'); - if(ext == NULL) { - newname = (char *)malloc(strlen(f) + strlen(newext) + 2); + namelen = (ext == NULL) ? strlen(f) : (ext - f); - if(newname) { - sprintf(newname, "%s.%s", f, newext); - } - } - else { - int len; + newname = (char *)calloc(namelen + strlen(newext) + 2, sizeof(char)); - len = (ext - f) + strlen(newext) + 2; - newname = (char *)malloc(len); + if(!newname) return NULL; - if(newname) { - strcpy(newname, f); - ext = strrchr(newname, '.') + 1; - strcpy(ext, newext); - } - } + strncpy(newname, f, namelen); + strcat(newname, "."); + strcat(newname, newext); return newname; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |