logconfig: fix config entry duplication 44/143844/5
authorMichal Bloch <m.bloch@samsung.com>
Fri, 11 Aug 2017 12:42:13 +0000 (14:42 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Fri, 11 Aug 2017 12:52:55 +0000 (12:52 +0000)
snprintf returns the number of written chars WITHOUT the null terminator,
even though it accepts the size WITH it.

This meant that even though the overwrite was successful,
the modification check always failed, leading the config
to think there was no existing entry and add another one.

Change-Id: Ic7e10e24258e0d54dc08f2c280f1f298569a282d
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/shared/logconfig.c

index 59fe6d5..18c7e75 100644 (file)
@@ -126,7 +126,7 @@ static int log_config_modify(struct log_config *config, const char *key, const c
 
        for (e = config->begin; e; e = e->next) {
                if (!strcmp(e->key, key))
-                       return snprintf(e->value, sizeof e->value, "%s", value) == (strlen(value) + 1);
+                       return snprintf(e->value, sizeof e->value, "%s", value) == (strlen(value));
        }
 
        return 0;