Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-vcs/git/files: git-1.7.1-noiconv-segfault-fix.patch
Date: Fri, 28 May 2010 20:27:47
Message-Id: 20100528202741.F24732CE3C@corvid.gentoo.org
1 robbat2 10/05/28 20:27:41
2
3 Added: git-1.7.1-noiconv-segfault-fix.patch
4 Log:
5 Bug #321895: patch from upstream to avoid segfault with USE=-iconv.
6 (Portage version: 2.2_rc67/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 dev-vcs/git/files/git-1.7.1-noiconv-segfault-fix.patch
10
11 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/git/files/git-1.7.1-noiconv-segfault-fix.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-vcs/git/files/git-1.7.1-noiconv-segfault-fix.patch?rev=1.1&content-type=text/plain
13
14 Index: git-1.7.1-noiconv-segfault-fix.patch
15 ===================================================================
16 commit 43acff34b902c38808ac0f326090f2516250e1f0
17 Author: Jonathan Nieder <jrnieder@×××××.com>
18 Date: Sat May 8 18:17:29 2010 -0500
19
20 cherry-pick: do not dump core when iconv fails
21
22 When cherry-picking, usually the new and old commit encodings are both
23 UTF-8. Most old iconv implementations do not support this trivial
24 conversion, so on old platforms, out->message remains NULL, and later
25 attempts to read it segfault.
26
27 Fix this by noticing the input and output encodings match and skipping
28 the iconv step, like the other reencode_string() call sites already do.
29 Also stop segfaulting on other iconv failures: if iconv fails for some
30 other reason, the best we can do is to pass the old message through.
31
32 This fixes a regression introduced in v1.7.1-rc0~15^2~2 (revert:
33 clarify label on conflict hunks, 2010-03-20).
34
35 Reported-by: Andreas Krey <a.krey@×××.de>
36 Signed-off-by: Jonathan Nieder <jrnieder@×××××.com>
37 Signed-off-by: Junio C Hamano <gitster@×××××.com>
38
39 diff --git a/builtin/revert.c b/builtin/revert.c
40 index 778a56e..7d68ef7 100644
41 --- a/builtin/revert.c
42 +++ b/builtin/revert.c
43 @@ -109,8 +109,13 @@ static int get_message(const char *raw_message, struct commit_message *out)
44 encoding = "UTF-8";
45 if (!git_commit_encoding)
46 git_commit_encoding = "UTF-8";
47 - if ((out->reencoded_message = reencode_string(raw_message,
48 - git_commit_encoding, encoding)))
49 +
50 + out->reencoded_message = NULL;
51 + out->message = raw_message;
52 + if (strcmp(encoding, git_commit_encoding))
53 + out->reencoded_message = reencode_string(raw_message,
54 + git_commit_encoding, encoding);
55 + if (out->reencoded_message)
56 out->message = out->reencoded_message;
57
58 abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);