From: Matthew Fredrickson Date: Fri, 15 Jun 2018 20:21:27 +0000 (-0500) Subject: menuselect/menuselect_curses: Resolves sprintf usage error X-Git-Tag: 15.5.0-rc1~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c53fcc76504da54c224cd6ccf27c69c6474b06c6;p=thirdparty%2Fasterisk.git menuselect/menuselect_curses: Resolves sprintf usage error 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 --- diff --git a/menuselect/menuselect_curses.c b/menuselect/menuselect_curses.c index 97f1f17149..0917eba62b 100644 --- a/menuselect/menuselect_curses.c +++ b/menuselect/menuselect_curses.c @@ -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)) {