Quality: Replace strcpy/strcat with bounded string functions #195
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: low
Category: quality / security
Location:
src/shared/file.c:37,src/shared/utils.c:15,23,32,34,55Description:
Several code paths use
strcpy()andstrcat()instead of bounded string functions. Although the current inputs are mostly from local CLI or small fixed strings, this is unsafe and blocks strict static analysis:file_create()insrc/shared/file.c:37copiespathinto a buffer allocated fromstrlen(path)+1. If the length calculation is ever wrong, this is a buffer overflow risk.str_dup()insrc/shared/utils.c:55usesstrcpy()and could be replaced withstrdup()ormemcpy.mkdir_r()insrc/shared/utils.c:15,23,32,34usesstrcpy()andstrcat()on stack buffers.Suggested fix:
strcpywithmemcpy+ explicit null termination orsnprintf(buf, size, "%s", src).strdup()where available (POSIX.1-2008) or add a boundedstr_duphelper.mkdir_rfor path-length overflow and simplify it withsnprintf/strncat.Labels: quality, security