DORMANTno replies

[PATCH] Another config file parsing fix.

From: sean <hidden>
Date: 2016-06-15 22:42:25
Subsystem: the rest · Maintainer: Linus Torvalds

If the variable we need to store should go into a section
that currently only has a single variable (not matching
the one we're trying to insert), we will already be into
the next section before we notice we've bypassed the correct
location to insert the variable.

To handle this case we store the current location as soon
as we find a variable matching the section of our new
variable.

Signed-off-by: Sean Estabrooks <redacted>


---

 config.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

1ba487db7393d773a2a4b7c404ba1b807272eb7d
diff --git a/config.c b/config.c
index 87fb220..41066e4 100644
--- a/config.c
+++ b/config.c
@@ -336,8 +336,10 @@ static int store_aux(const char* key, co
 			store.state = KEY_SEEN;
 			store.seen++;
 		} else if (strrchr(key, '.') - key == store.baselen &&
-			      !strncmp(key, store.key, store.baselen))
+			      !strncmp(key, store.key, store.baselen)) {
 					store.state = SECTION_SEEN;
+					store.offset[store.seen] = ftell(config_file);
+		}
 	}
 	return 0;
 }
-- 
1.3.2.g6e99a-dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help