From 35084eaadf8b37f5c4a325f0d4b01767753ee9c3 Mon Sep 17 00:00:00 2001 From: Dusan Durech Date: Sat, 15 Nov 2008 16:08:21 +0100 Subject: modification coding stile --- src/client/configFile.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/client/configFile.c') diff --git a/src/client/configFile.c b/src/client/configFile.c index afdbf9f..74509fe 100644 --- a/src/client/configFile.c +++ b/src/client/configFile.c @@ -30,18 +30,22 @@ int getValue(char *line, char *env, char *val, int len) strcpy(clone_env, env); offset_env = strstr(line, clone_env); + if (offset_env == NULL) return -1; offset_val_begin = strchr(offset_env, '"'); + if (offset_val_begin == NULL) return -1; offset_val_end = strchr(offset_val_begin + 1, '"'); + if (offset_val_end == NULL) return -1; val_len = (int) (offset_val_end - (offset_val_begin + 1)); + if (val_len > len - 1) val_len = len - 1; @@ -63,14 +67,17 @@ char *setValue(char *line, char *env, char *val) strcpy(clone_env, env); offset_env = strstr(line, clone_env); + if (offset_env == NULL) return NULL; offset_val_begin = strchr(offset_env, '"'); + if (offset_val_begin == NULL) return NULL; offset_val_end = strchr(offset_val_begin + 1, '"'); + if (offset_val_end == NULL) return NULL; @@ -124,9 +131,7 @@ int setValueInConfigFile(textFile_t * textFile, char *env, char *val) return -1; } -void -loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len, - char *butVal) +void loadValueFromConfigFile(textFile_t * textFile, char *env, char *val, int len, char *butVal) { strcpy(val, butVal); -- cgit v1.2.3