From: Sebastian Harl Date: Tue, 3 Feb 2009 09:40:23 +0000 (+0100) Subject: debian/patches: Added mem-corruption-fix.dpatch. X-Git-Tag: tig-0.13-1~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e4436c97e988d7ddcf2301a9f5583949b7ef6a87;p=pkg-tig.git debian/patches: Added mem-corruption-fix.dpatch. Upstream patch fixing memory corruption when updating the tree view. --- diff --git a/debian/changelog b/debian/changelog index 4cf93a9..52ad792 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,8 +7,10 @@ tig (0.13-1) experimental; urgency=low handling of non-UTF-8 locales. - Added tigrc-parsing-fix.dpatch - upstream patch fixing a regression in parsing ~/.tigrc. + - Added mem-corruption-fix.dpatch - upstream patch fixing memory + corruption when updating the tree view. - -- Sebastian Harl Tue, 03 Feb 2009 10:37:15 +0100 + -- Sebastian Harl Tue, 03 Feb 2009 10:39:26 +0100 tig (0.12.1-1) experimental; urgency=low diff --git a/debian/patches/00list b/debian/patches/00list index 8857e8b..882e105 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -1,3 +1,4 @@ non-utf8-fix.dpatch tigrc-parsing-fix.dpatch +mem-corruption-fix.dpatch diff --git a/debian/patches/mem-corruption-fix.dpatch b/debian/patches/mem-corruption-fix.dpatch new file mode 100755 index 0000000..b4fd19b --- /dev/null +++ b/debian/patches/mem-corruption-fix.dpatch @@ -0,0 +1,60 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## mem-corruption-fix.dpatch by Jonas Fonseca +## +## DP: Fix memory corruption bug in tree_read when sorting the entries +## DP: +## DP: Triggered by defining ITEM_CHUNK_SIZE to 1. + +diff git a/tig.c b/tig.c +--- a/tig.c ++++ b/tig.c +@@ -3614,7 +3614,7 @@ static bool + { + size_t textlen = text ? strlen(text) : 0; + char buf[SIZEOF_STR]; +- unsigned long pos; ++ size_t pos; + enum line_type type; + bool first_read = view->lines == 0; + +@@ -3645,8 +3645,12 @@ tree_read(struct view *view, char *text) + return FALSE; + } + ++ if (!add_line_text(view, text, type)) ++ return FALSE; ++ text = view->line[view->lines - 1].data; ++ + /* Skip "Directory ..." and ".." line. */ +- for (pos = 1 + !!*opt_path; pos < view->lines; pos++) { ++ for (pos = 1 + !!*opt_path; pos < view->lines - 1; pos++) { + struct line *line = &view->line[pos]; + const char *path1 = tree_path(line); + char *path2 = text + SIZEOF_TREE_ATTR; +@@ -3655,24 +3659,16 @@ tree_read(struct view *view, char *text) + if (cmp <= 0) + continue; + +- text = strdup(text); +- if (!text) +- return FALSE; +- +- if (view->lines > pos) ++ if (view->lines - 1 > pos) + memmove(&view->line[pos + 1], &view->line[pos], +- (view->lines - pos) * sizeof(*line)); ++ (view->lines - 1 - pos) * sizeof(*line)); + + line = &view->line[pos]; + line->data = text; + line->type = type; +- view->lines++; + return TRUE; + } + +- if (!add_line_text(view, text, type)) +- return FALSE; +- + if (tree_lineno > view->lineno) { + view->lineno = tree_lineno; + tree_lineno = 0;