Fixed potential path truncation in case-insensitive file lookup
authorRobert Pengelly <robertapengelly@hotmail.com>
Tue, 20 Oct 2026 10:24:14 +0000 (11:24 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Tue, 20 Oct 2026 10:24:14 +0000 (11:24 +0100)
interrupts.c

index 77c3fcbe5c5990e933f2f24697ff0e381718c192..68e19a58fcd015cbc68d6f0448cb2f2ad49cf869 100644 (file)
@@ -3246,7 +3246,6 @@ FILE *dos_fopen_case_insensitive (const char *path, const char *mode) {
     DIR *d;
     
     dos_split_dir_pattern (path, dir, sizeof (dir), name, sizeof (name));
-    
     d = opendir (dir[0] ? dir : ".");
     
     if (!d) {
@@ -3257,10 +3256,11 @@ FILE *dos_fopen_case_insensitive (const char *path, const char *mode) {
     
         if (strcasecmp (ent->d_name, name) == 0) {
         
-            char full[512];
-            snprintf (full, sizeof (full), "%s/%s", dir[0] ? dir : ".", ent->d_name);
+            char full[520];
             
+            snprintf (full, sizeof (full), "%s/%s", dir[0] ? dir : ".", ent->d_name);
             closedir (d);
+            
             return fopen (full, mode);
         
         }