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:
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user