{"thread":{"id":"33194","subject":"[PATCH] index-pack: fix buffer overflow caused by translations","startedAt":"2013-03-16T01:25:18Z","lastAt":"2013-03-16T01:25:18Z","messageCount":1,"participants":["Nguyễn Thái Ngọc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"211424","messageId":"1363397118-16015-1-git-send-email-pclouds@gmail.com","threadId":"33194","inReplyTo":null,"subject":"[PATCH] index-pack: fix buffer overflow caused by translations","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2013-03-16T01:25:18Z","receivedAt":"2013-03-16T01:25:18Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"The translation of \"completed with %d local objects\" is put in a\n48-byte buffer, which may be enough for English but not true for any\ntranslations. Convert it to use strbuf (i.e. no hard limit on\ntranslation length).\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n My bad, I should have checked this when I marked this string for\n translation. At least recent Vietnamese translation triggers this.\n\n builtin/index-pack.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 43d364b..ef62124 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -1099,7 +1099,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha\n \tif (fix_thin_pack) {\n \t\tstruct sha1file *f;\n \t\tunsigned char read_sha1[20], tail_sha1[20];\n-\t\tchar msg[48];\n+\t\tstruct strbuf msg = STRBUF_INIT;\n \t\tint nr_unresolved = nr_deltas - nr_resolved_deltas;\n \t\tint nr_objects_initial = nr_objects;\n \t\tif (nr_unresolved <= 0)\n@@ -1109,9 +1109,10 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha\n \t\t\t\t   * sizeof(*objects));\n \t\tf = sha1fd(output_fd, curr_pack);\n \t\tfix_unresolved_deltas(f, nr_unresolved);\n-\t\tsprintf(msg, _(\"completed with %d local objects\"),\n-\t\t\tnr_objects - nr_objects_initial);\n-\t\tstop_progress_msg(&progress, msg);\n+\t\tstrbuf_addf(&msg, _(\"completed with %d local objects\"),\n+\t\t\t    nr_objects - nr_objects_initial);\n+\t\tstop_progress_msg(&progress, msg.buf);\n+\t\tstrbuf_release(&msg);\n \t\tsha1close(f, tail_sha1, 0);\n \t\thashcpy(read_sha1, pack_sha1);\n \t\tfixup_pack_header_footer(output_fd, pack_sha1,\n-- \n1.8.2.82.gc24b958.dirty\n"}]}