From 3ec034e1725f6f6eb911a706de33b1ac44845021 Mon Sep 17 00:00:00 2001 From: Image <> Date: Sat, 6 Jun 2020 07:58:17 -0400 Subject: [PATCH] db ini checks Fixes #128 Also addresses telling the correct parameter that is missing from the ini --- EQ2/source/common/database.cpp | 2 +- EQ2/source/common/dbcore.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/EQ2/source/common/database.cpp b/EQ2/source/common/database.cpp index baaef8afd..9f1ef7d66 100644 --- a/EQ2/source/common/database.cpp +++ b/EQ2/source/common/database.cpp @@ -104,7 +104,7 @@ bool Database::Init(bool silentLoad) { for (i = 0; i < 4; i++) { if ( !items[i] ) - LogWrite(DATABASE__ERROR, 0, "DB", "Could not find parameter %s", exampleIni[i]); + LogWrite(DATABASE__ERROR, 0, "DB", "Could not find parameter %s", exampleIni[i+1]); // offset by 1 because the [Database] entry } LogWrite(DATABASE__ERROR, 0, "DB", "Example File:"); int length = sizeof exampleIni / sizeof exampleIni[0]; diff --git a/EQ2/source/common/dbcore.cpp b/EQ2/source/common/dbcore.cpp index c9a6c61b2..ce4a6a25f 100644 --- a/EQ2/source/common/dbcore.cpp +++ b/EQ2/source/common/dbcore.cpp @@ -100,12 +100,23 @@ bool DBcore::ReadDBINI(char* host, char* user, char* passwd, char* database, int key = strtok(line, "="); + if (key == NULL) + continue; + //don't do anything until we find the [Database] section if (!on_database_section && strncasecmp(key, "[Database]", 10) == 0) on_database_section = true; else { val = strtok(NULL, "="); + if (val == NULL) + { + if (strcasecmp(key, "password") == 0) { + strcpy(passwd, ""); + items[2] = true; + } + continue; + } if (strcasecmp(key, "host") == 0) { strcpy(host, val); items[0] = true;