fix(tests): fix UB in mk{fifo,nod,nodat}

Memory chunk is allocated with `malloc` and used as the `dest` buffer
for `strncat`. The `dest` argument in `strncat` has to be NUL terminated,
however it was not.

This commit fixes this issue in mk{fifo,nod,noat}.c.

Almost all dynamic tests pass now.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2024-11-26 16:56:05 +11:00
parent 22bbdb025c
commit cdb4843164
3 changed files with 6 additions and 0 deletions
+2
View File
@@ -11,7 +11,9 @@ int main(void) {
char temp[] = "/tmp/stattest-XXXXXX";
const char file[] = "/mkfifo_fifo";
int len = sizeof(temp) + sizeof(file);
char* path = malloc(len * sizeof(char));
path[0] = '\0';
if (path == NULL) {
fprintf(stderr, "Could not allocate: %s\n", strerror(errno));
+2
View File
@@ -11,7 +11,9 @@ int main(void) {
char temp[] = "/tmp/stattest-XXXXXX";
const char file[] = "/mknod";
int len = sizeof(temp) + sizeof(file);
char* path = malloc(len * sizeof(char));
path[0] = '\0';
if (path == NULL) {
fprintf(stderr, "Could not allocate: %s\n", strerror(errno));
+2
View File
@@ -12,7 +12,9 @@ int main(void) {
const char separator[] = "/";
const char file[] = "mknod"; // relative
int len = sizeof(temp) + sizeof(file) + sizeof(separator);
char* path = malloc(len * sizeof(char));
path[0] = '\0';
if (path == NULL) {
fprintf(stderr, "Could not allocate: %s\n", strerror(errno));