From d46db2f648e7d00ae138fb98bd0ee49014c501a6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 18 Sep 2011 11:46:39 -0700 Subject: Avoid a buffer underrun when getting the end of a config option value --- Alc/alcConfig.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Alc/alcConfig.c b/Alc/alcConfig.c index 82375f40..b8c04743 100644 --- a/Alc/alcConfig.c +++ b/Alc/alcConfig.c @@ -62,7 +62,7 @@ static void LoadConfigFromFile(FILE *f) while(fgets(buffer, sizeof(buffer), f)) { - size_t i = 0; + ssize_t i = 0; while(isspace(buffer[i])) i++; @@ -74,6 +74,7 @@ static void LoadConfigFromFile(FILE *f) if(buffer[0] == '[') { ConfigBlock *nextBlock; + size_t i; i = 1; while(buffer[i] && buffer[i] != ']') @@ -194,7 +195,7 @@ static void LoadConfigFromFile(FILE *f) i++; do { i--; - } while(isspace(buffer[i])); + } while(i >= 0 && isspace(buffer[i])); buffer[++i] = 0; free(ent->value); -- cgit v1.2.3