]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Fix hardfile2 geometry file parsing, replace unsafe characters in autogenerated geome...
authorToni Wilen <twilen@winuae.net>
Sat, 18 Nov 2023 13:25:21 +0000 (15:25 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 18 Nov 2023 13:25:21 +0000 (15:25 +0200)
cfgfile.cpp
include/fsdb.h
od-win32/fsdb_mywin32.cpp
od-win32/fsdb_win32.cpp
od-win32/hardfile_win32.cpp

index 4896ef3ffaa9601426ab1342a4d646a5554d234e..40df0b421cc6abc70da796a9931b4bfc4d9d191d 100644 (file)
@@ -5317,14 +5317,14 @@ static int cfgfile_parse_newfilesys (struct uae_prefs *p, int nr, int type, TCHA
                                if (getintval2 (&tmpp2, &uci.highcyl, ',', false)) {
                                        getintval (&tmpp2, &uci.pcyls, '/');
                                        getintval (&tmpp2, &uci.pheads, '/');
-                                       getintval2 (&tmpp2, &uci.psecs, '/', true);
+                                       getintval2 (&tmpp2, &uci.psecs, ',', true);
                                        if (uci.pheads && uci.psecs) {
                                                uci.physical_geometry = true;
                                        } else {
                                                uci.pheads = uci.psecs = uci.pcyls = 0;
                                                uci.physical_geometry = false;
                                        }
-                                       if (tmpp2[0]) {
+                                       if (tmpp2 && tmpp2[0]) {
                                                if (tmpp2[0] == '\"') {
                                                        n = cfgfile_unescape (tmpp2, &end, 0, false);
                                                        if (!n)
index 5fe8f7296e3b67277fc520385e39426ae77ac5a9..a5a037cace2786e667d196cdf5e5b94768ce3feb 100644 (file)
@@ -184,6 +184,7 @@ extern int my_issamevolume(const TCHAR *path1, const TCHAR *path2, TCHAR *path);
 extern bool my_issamepath(const TCHAR *path1, const TCHAR *path2);
 extern bool my_createsoftlink(const TCHAR *path, const TCHAR *target);
 extern bool my_createshortcut(const TCHAR *source, const TCHAR *target, const TCHAR *description);
+extern void makesafefilename(TCHAR*, bool);
 
 extern a_inode *custom_fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname);
 extern a_inode *custom_fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname);
index 9d2eb2ddc5187ef1ed03228081a9a0ca5b411b41..8043c55ca647be00aa486e030658be628b37ae8a 100644 (file)
@@ -1054,4 +1054,3 @@ const TCHAR *my_getfilepart(const TCHAR *filename)
                return p + 1;
        return filename;
 }
-
index bc8b298d37f49129f600cd427be6da71e2450a76..491dda1e6a57bc54ae32ee2c7798f0260d708a3c 100644 (file)
@@ -51,6 +51,22 @@ static TCHAR evilchars[NUM_EVILCHARS] = { '\\', '*', '?', '\"', '<', '>', '|' };
 *        1632
 */
 
+void makesafefilename(TCHAR *s, bool evilonly)
+{
+       TCHAR *c;
+
+       for (int i = 0; i < NUM_EVILCHARS; i++)
+               while ((c = _tcschr(s, evilchars[i])) != 0)
+                       *c = '_';
+
+       if (!evilonly) {
+               while ((c = _tcschr(s, '.')) != 0)
+                       *c = '_';
+               while ((c = _tcschr(s, ' ')) != 0)
+                       *c = '_';
+       }
+}
+
 static TCHAR *make_uaefsdbpath (const TCHAR *dir, const TCHAR *name)
 {
        size_t len;
@@ -602,21 +618,13 @@ int fsdb_mode_representable_p (const a_inode *aino, int amigaos_mode)
 
 TCHAR *fsdb_create_unique_nname (a_inode *base, const TCHAR *suggestion)
 {
-       TCHAR *c;
        TCHAR tmp[256] = UAEFSDB_BEGINS;
        int i;
 
        _tcsncat (tmp, suggestion, 240);
 
        /* replace the evil ones... */
-       for (i = 0; i < NUM_EVILCHARS; i++)
-               while ((c = _tcschr (tmp, evilchars[i])) != 0)
-                       *c = '_';
-
-       while ((c = _tcschr (tmp, '.')) != 0)
-               *c = '_';
-       while ((c = _tcschr (tmp, ' ')) != 0)
-               *c = '_';
+       makesafefilename(tmp, false);
 
        for (;;) {
                TCHAR *p = build_nname (base->nname, tmp);
index 7aea3555166d78d994022ddcce3a0ed1868910bc..0eaf877e37dfa64abd3546c2fd5893f8f8938377 100644 (file)
@@ -19,6 +19,7 @@
 #include "memory.h"
 #include "autoconf.h"
 #include "rommgr.h"
+#include "fsdb.h"
 
 #define hfd_log write_log
 #define hfd_log2
@@ -1662,6 +1663,7 @@ doout:
                _stprintf(geometry_file + _tcslen(geometry_file), _T(" %llX"), udi->size);
        if (geometry_file[0])
                _tcscat(geometry_file, _T(".geo"));
+       makesafefilename(geometry_file, true);
 
        stringboxdialogactive = 1;
        hdini = ini;