]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
menuselect/menuselect_curses: Resolves sprintf usage error
authorMatthew Fredrickson <creslin@digium.com>
Fri, 15 Jun 2018 20:21:27 +0000 (15:21 -0500)
committerMatthew Fredrickson <creslin@digium.com>
Tue, 19 Jun 2018 14:43:46 +0000 (08:43 -0600)
Acccording to the man page for sprintf, using the same buffer for
output as one used as an input yields undefined behavior.
This patch should work around this problem.

ASTERISK-27903
Reported-by: Alexander Traud
Change-Id: I2213dcb454aff26457e2e4cc9c6821276463ae3a

menuselect/menuselect_curses.c

index 97f1f171497ba9e8a0a5e4725a958416986a2758..0917eba62b1b46c411758ea4cf88e5b1b3142e05 100644 (file)
@@ -227,7 +227,7 @@ static void display_mem_info(WINDOW *menu, struct member *mem, int start_y, int
                                buf[0] = '\0';
                                new_line = 1;
                        }
-                       sprintf(buf, "%s%*.*s%s", buf, new_line ? 0 : 1, new_line ? 0 : 1, " ", word);
+                       sprintf(buf + strlen(buf), "%*.*s%s", new_line ? 0 : 1, new_line ? 0 : 1, " ", word);
                        new_line = 0;
                }
                if (strlen(buf)) {