summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-12 21:50:34 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-12 21:50:34 +0100
commitcceee6b8e23138e5a16e6aef23759a8c60ef872e (patch)
tree4a743b186828a6eacdd904e4868e9fc3ad1a153e
parent9064f7b9c347f913089bfea94d65ad3afc11ccf4 (diff)
Fix crash in getconfstr() when not finding certain strings in configuration file.
-rw-r--r--config.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/config.c b/config.c
index 168b780..78190f5 100644
--- a/config.c
+++ b/config.c
@@ -7,6 +7,7 @@ int getconfstr(char *confname, char *filename, char* dest) {
FILE *fp;
char *ret;
char str[MAXCHAR];
+ int found = 0; // Have we found the configuration option?
// Set strings to zero-length to begin
dest[0] = '\0';
@@ -39,14 +40,14 @@ int getconfstr(char *confname, char *filename, char* dest) {
// If the resulting temporary string contains the requested option name,
// we have found our configuration option and it is in the current 'str'
if (!(ret = strstr(substr, confname)) == 0) {
+ found = 1;
break;
}
}
// If we got here, then either we found the configuration option or we ran out of file
- // If str is NULL then we ran out of file
- if (ret == NULL) {
+ if (!found) {
printf("Error reading configuration option '%s', did not find it in configuration file '%s'.\n", confname, filename);
return 0;
}