]> git.earman.xyz Git - sensor-watch.git/commitdiff
Fix cat command
authorJames Haggerty <james@gruemail.com>
Sun, 12 Feb 2023 09:27:48 +0000 (20:27 +1100)
committerJames Haggerty <james@gruemail.com>
Sun, 12 Feb 2023 09:27:48 +0000 (20:27 +1100)
If we ran into a heap that wasn't filled with '\0', fun things.

movement/filesystem.c

index 2b345eda8550030af454ea11144c0263b1ce43e9..97e35455d71e53bdbe2f297e97fa945a08b666ae 100644 (file)
@@ -196,6 +196,7 @@ static void filesystem_cat(char *filename) {
         if (info.size > 0) {
             char *buf = malloc(info.size + 1);
             filesystem_read_file(filename, buf, info.size);
+            buf[info.size] = '\0';
             printf("%s\n", buf);
             free(buf);
         } else {