From 0a65870357d557e85c4f4bae005749145190a33f Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 9 Sep 2018 20:08:50 +0300 Subject: [PATCH] Off by one string length fix. --- od-win32/registry.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); -- 2.47.3