{"thread":{"id":"45158","subject":"[PATCH v3 0/2] Fix l10n","startedAt":"2017-02-16T23:33:08Z","lastAt":"2017-02-16T23:33:12Z","messageCount":3,"participants":["Maxim Moseychuk"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"311827","messageId":"20170216233249.24757-1-franchesko.salias.hudro.pedros@gmail.com","threadId":"45158","inReplyTo":null,"subject":"[PATCH v3 0/2] Fix l10n","fromName":"Maxim Moseychuk","fromEmail":"franchesko.salias.hudro.pedros@gmail.com","sentAt":"2017-02-16T23:32:47Z","receivedAt":"2017-02-16T23:33:08Z","isPatch":true,"sender":{"key":"franchesko.salias.hudro.pedros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3121341?v=4"},"body":"In some places fixed-size buffers can't store formatted string.\nIf it be happen then git die.\n\nJonathan Tan, Jeff King thanks a lot for your help.\nThis is really my first patches. Your help is invaluable.\n\nMaxim Moseychuk (2):\n  bisect_next_all(): fix bisect crash when used the gettext translation\n  stop_progress_msg(): simplification function\n\n bisect.c   |  9 +++++----\n progress.c | 11 ++++-------\n 2 files changed, 9 insertions(+), 11 deletions(-)\n\n--\n2.11.1\n\n"},{"id":"311828","messageId":"20170216233249.24757-2-franchesko.salias.hudro.pedros@gmail.com","threadId":"45158","inReplyTo":"20170216233249.24757-1-franchesko.salias.hudro.pedros@gmail.com","subject":"[PATCH v3 1/2] bisect_next_all(): fix bisect crash when used the gettext translation","fromName":"Maxim Moseychuk","fromEmail":"franchesko.salias.hudro.pedros@gmail.com","sentAt":"2017-02-16T23:32:48Z","receivedAt":"2017-02-16T23:33:10Z","isPatch":true,"sender":{"key":"franchesko.salias.hudro.pedros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3121341?v=4"},"body":"The buffer steps_msg[32] is too small.\nTranslated \"(roughly %d step)\" string can not be located in the buffer.\n\nSolution: using xstrfmt which dynamically allocates memory.\n\nDummy solution: just increase steps_msg size but is not safe.\nThat feels pretty hacky, though. In practice the set of translations is\ncontained, but it doesn't have to be (and certainly nobody would notice\nif a new translation was added with a longer name until a user\ncomplained).\n\nReproduce bug: \"LANG=ru_RU.UTF8 git bisect start v4.9 v4.8\" on linux sources.\n\nSigned-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>\n---\n bisect.c | 9 +++++----\n 1 file changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 21bc6daa4..787543cad 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -940,7 +940,7 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \tstruct commit_list *tried;\n \tint reaches = 0, all = 0, nr, steps;\n \tconst unsigned char *bisect_rev;\n-\tchar steps_msg[32];\n+\tchar *steps_msg;\n \n \tread_bisect_terms(&term_bad, &term_good);\n \tif (read_bisect_refs())\n@@ -990,14 +990,15 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \n \tnr = all - reaches - 1;\n \tsteps = estimate_bisect_steps(all);\n-\txsnprintf(steps_msg, sizeof(steps_msg),\n-\t\t  Q_(\"(roughly %d step)\", \"(roughly %d steps)\", steps),\n-\t\t  steps);\n+\n+\tsteps_msg = xstrfmt(Q_(\"(roughly %d step)\", \"(roughly %d steps)\",\n+\t\t  steps), steps);\n \t/* TRANSLATORS: the last %s will be replaced with\n \t   \"(roughly %d steps)\" translation */\n \tprintf(Q_(\"Bisecting: %d revision left to test after this %s\\n\",\n \t\t  \"Bisecting: %d revisions left to test after this %s\\n\",\n \t\t  nr), nr, steps_msg);\n+\tfree(steps_msg);\n \n \treturn bisect_checkout(bisect_rev, no_checkout);\n }\n-- \n2.11.1\n\n"},{"id":"311829","messageId":"20170216233249.24757-3-franchesko.salias.hudro.pedros@gmail.com","threadId":"45158","inReplyTo":"20170216233249.24757-1-franchesko.salias.hudro.pedros@gmail.com","subject":"[PATCH v3 2/2] stop_progress_msg(): simplification function","fromName":"Maxim Moseychuk","fromEmail":"franchesko.salias.hudro.pedros@gmail.com","sentAt":"2017-02-16T23:32:49Z","receivedAt":"2017-02-16T23:33:12Z","isPatch":true,"sender":{"key":"franchesko.salias.hudro.pedros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3121341?v=4"},"body":"stop_progress_msg() is rarely used and is not demanding to\nperformance. Use dynamically allocates memory.\n\nSigned-off-by: Maxim Moseychuk <franchesko.salias.hudro.pedros@gmail.com>\n---\n progress.c | 11 ++++-------\n 1 file changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/progress.c b/progress.c\nindex 76a88c573..29378caa0 100644\n--- a/progress.c\n+++ b/progress.c\n@@ -243,21 +243,18 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)\n \t*p_progress = NULL;\n \tif (progress->last_value != -1) {\n \t\t/* Force the last update */\n-\t\tchar buf[128], *bufp;\n-\t\tsize_t len = strlen(msg) + 5;\n+\t\tchar *buf;\n \t\tstruct throughput *tp = progress->throughput;\n \n-\t\tbufp = (len < sizeof(buf)) ? buf : xmallocz(len);\n \t\tif (tp) {\n \t\t\tunsigned int rate = !tp->avg_misecs ? 0 :\n \t\t\t\t\ttp->avg_bytes / tp->avg_misecs;\n \t\t\tthroughput_string(&tp->display, tp->curr_total, rate);\n \t\t}\n \t\tprogress_update = 1;\n-\t\txsnprintf(bufp, len + 1, \", %s.\\n\", msg);\n-\t\tdisplay(progress, progress->last_value, bufp);\n-\t\tif (buf != bufp)\n-\t\t\tfree(bufp);\n+\t\tbuf = xstrfmt(\", %s.\\n\", msg);\n+\t\tdisplay(progress, progress->last_value, buf);\n+\t\tfree(buf);\n \t}\n \tclear_progress_signal();\n \tif (progress->throughput)\n-- \n2.11.1\n\n"}]}