[PATCH 00/24] nd/untracked-cache updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Compared to 'pu', this fixes two bugs (in 01/24 and 10/24) and one
style vololation (in 11/24), found by Junio and Stefan. Diff

-- 8< --
diff --git a/dir.c b/dir.c
index b8a4f9e..8a037ee 100644
--- a/dir.c
+++ b/dir.c
@@ -687,7 +687,8 @@ static int add_excludes(const char *fname, const char *base, int baselen,
 			else if (check_index &&
 				 (pos = cache_name_pos(fname, strlen(fname))) >= 0 &&
 				 !ce_stage(active_cache[pos]) &&
-				 ce_uptodate(active_cache[pos]))
+				 ce_uptodate(active_cache[pos]) &&
+				 !would_convert_to_git(fname, NULL, 0, 0))
 				hashcpy(sha1_stat->sha1, active_cache[pos]->sha1);
 			else
 				hash_sha1_file(buf, size, "blob", sha1_stat->sha1);
@@ -2308,6 +2309,9 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra
 	strbuf_add(out, untracked->ident.buf, untracked->ident.len);
 
 	strbuf_add(out, ouc, ouc_size(len));
+	free(ouc);
+	ouc = NULL;
+
 	if (!untracked->root) {
 		varint_len = encode_varint(0, varbuf);
 		strbuf_add(out, varbuf, varint_len);
@@ -2388,11 +2392,6 @@ static void stat_data_from_disk(struct stat_data *to, const struct stat_data *fr
 static int read_one_dir(struct untracked_cache_dir **untracked_,
 			struct read_data *rd)
 {
-#define NEXT(x) \
-	next = data + (x); \
-	if (next > rd->end) \
-		return -1;
-
 	struct untracked_cache_dir ud, *untracked;
 	const unsigned char *next, *data = rd->data, *end = rd->end;
 	unsigned int value;
@@ -2419,7 +2418,9 @@ static int read_one_dir(struct untracked_cache_dir **untracked_,
 	data = next;
 
 	len = strlen((const char *)data);
-	NEXT(len + 1);
+	next = data + len + 1;
+	if (next > rd->end)
+		return -1;
 	*untracked_ = untracked = xmalloc(sizeof(*untracked) + len);
 	memcpy(untracked, &ud, sizeof(ud));
 	memcpy(untracked->name, data, len + 1);
@@ -2427,7 +2428,9 @@ static int read_one_dir(struct untracked_cache_dir **untracked_,
 
 	for (i = 0; i < untracked->untracked_nr; i++) {
 		len = strlen((const char *)data);
-		NEXT(len + 1);
+		next = data + len + 1;
+		if (next > rd->end)
+			return -1;
 		untracked->untracked[i] = xstrdup((const char*)data);
 		data = next;
 	}
-- 8< --
-- 
2.3.0.rc1.137.g477eb31

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]