From d83c11faa2f876b3eb5921be0e26cd0909f1a548 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 3 Nov 2007 09:59:39 +0000 Subject: [PATCH] Host OS name representation must be large enough to handle any kind of native encoding (e.g. UTF-8 on MacOS X). --- BasiliskII/src/extfs.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/BasiliskII/src/extfs.cpp b/BasiliskII/src/extfs.cpp index dd3615a9..1f989b34 100644 --- a/BasiliskII/src/extfs.cpp +++ b/BasiliskII/src/extfs.cpp @@ -158,8 +158,8 @@ struct FSItem { uint32 id; // CNID of this file/dir uint32 parent_id; // CNID of parent file/dir FSItem *parent; // Pointer to parent - char name[32]; // Object name (C string) - Host OS - char guest_name[32]; // Object name (C string) - Guest OS + char *name; // Object name (C string) - Host OS + char guest_name[32]; // Object name (C string) - Guest OS time_t mtime; // Modification time for get_cat_info caching int cache_dircount; // Cached number of files in directory }; @@ -235,8 +235,8 @@ static FSItem *create_fsitem(const char *name, const char *guest_name, FSItem *p p->id = next_cnid++; p->parent_id = parent->id; p->parent = parent; - strncpy(p->name, name, 31); - p->name[31] = 0; + p->name = new char[strlen(name) + 1]; + strcpy(p->name, name); strncpy(p->guest_name, guest_name, 31); p->guest_name[31] = 0; p->mtime = 0; @@ -416,6 +416,7 @@ void ExtFSInit(void) p->id = ROOT_PARENT_ID; p->parent_id = 0; p->parent = NULL; + p->name = new char[1]; p->name[0] = 0; p->guest_name[0] = 0; @@ -427,8 +428,9 @@ void ExtFSInit(void) p->id = ROOT_ID; p->parent_id = ROOT_PARENT_ID; p->parent = first_fs_item; - strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32); - p->name[31] = 0; + const char *volume_name = GetString(STR_EXTFS_VOLUME_NAME); + p->name = new char[strlen(volume_name) + 1]; + strcpy(p->name, volume_name); strncpy(p->guest_name, host_encoding_to_macroman(p->name), 32); p->guest_name[31] = 0; @@ -453,6 +455,7 @@ void ExtFSExit(void) FSItem *p = first_fs_item, *next; while (p) { next = p->next; + delete[] p->name; delete p; p = next; }