From: Toni Wilen Date: Sun, 9 Sep 2018 17:08:50 +0000 (+0300) Subject: Off by one string length fix. X-Git-Tag: 4100~84 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=0a65870357d557e85c4f4bae005749145190a33f;p=francis%2Fwinuae.git Off by one string length fix. --- diff --git a/od-win32/registry.cpp b/od-win32/registry.cpp index e89abd66..533e4282 100644 --- a/od-win32/registry.cpp +++ b/od-win32/registry.cpp @@ -134,8 +134,8 @@ int regquerystr (UAEREG *root, const TCHAR *name, TCHAR *str, int *size) int ret = 0; TCHAR *tmp = NULL; if (ini_getstring(inidata, gs(root), name, &tmp)) { - if (_tcslen(tmp) > *size) - tmp[*size] = 0; + if (_tcslen(tmp) >= *size) + tmp[(*size) - 1] = 0; _tcscpy (str, tmp); *size = _tcslen(str); ret = 1; @@ -163,10 +163,10 @@ int regenumstr (UAEREG *root, int idx, TCHAR *name, int *nsize, TCHAR *str, int int ret = ini_getsectionstring(inidata, gs(root), idx, &name2, &str2); if (ret) { if (_tcslen(name2) >= *nsize) { - name2[*nsize] = 0; + name2[(*nsize) - 1] = 0; } if (_tcslen(str2) >= *size) { - str2[*size] = 0; + str2[(*size) - 1] = 0; } _tcscpy(name, name2); _tcscpy(str, str2);