[PATCH] Fix filename scaling for binary files

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

 



Set maximum filename length for binary files so that scaling won't be
triggered and result in invalid string access.

Signed-off-by: Jonas Fonseca <fonseca@xxxxxxx>

---

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

diff --git a/diff.c b/diff.c
index b54bbfa..ddcfb84 100644
--- a/diff.c
+++ b/diff.c
@@ -250,13 +250,14 @@ static void show_stats(struct diffstat_t
 	for (i = 0; i < data->nr; i++) {
 		struct diffstat_file *file = data->files[i];
 
+		len = strlen(file->name);
+		if (max_len < len)
+			max_len = len;
+
 		if (file->is_binary || file->is_unmerged)
 			continue;
 		if (max_change < file->added + file->deleted)
 			max_change = file->added + file->deleted;
-		len = strlen(file->name);
-		if (max_len < len)
-			max_len = len;
 	}
 
 	for (i = 0; i < data->nr; i++) {

-- 
Jonas Fonseca
-
: 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]