Commit 822645f6298ae0ff86fa717a79c5b7e105bc4a0d

Vicent Marti 2013-05-02T17:48:49

refdb_fs: Only strstr the traits line

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 6a6f589..2c45eab 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -216,8 +216,13 @@ static int packed_load(refdb_fs_backend *backend)
 		static const char *traits_header = "# pack-refs with: "; 
 
 		if (git__prefixcmp(buffer_start, traits_header) == 0) {
-			const char *traits = buffer_start + strlen(traits_header);
-			const char *traits_end = strchr(traits, '\n');
+			char *traits = (char *)buffer_start + strlen(traits_header);
+			char *traits_end = strchr(traits, '\n');
+
+			if (traits_end == NULL)
+				goto parse_failed;
+
+			*traits_end = '\0';
 
 			if (strstr(traits, " fully-peeled ") != NULL) {
 				backend->peeling_mode = PEELING_FULL;