[Asterisk-code-review] menuselect/menuselect curses: Resolves sprintf usage error (asterisk[13])

Matthew Fredrickson asteriskteam at digium.com
Tue Jun 19 09:43:32 CDT 2018


Matthew Fredrickson has uploaded this change for review. ( https://gerrit.asterisk.org/9201


Change subject: menuselect/menuselect_curses: Resolves sprintf usage error
......................................................................

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
---
M menuselect/menuselect_curses.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/9201/1

diff --git a/menuselect/menuselect_curses.c b/menuselect/menuselect_curses.c
index 97f1f17..0917eba 100644
--- a/menuselect/menuselect_curses.c
+++ b/menuselect/menuselect_curses.c
@@ -227,7 +227,7 @@
 				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)) {

-- 
To view, visit https://gerrit.asterisk.org/9201
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2213dcb454aff26457e2e4cc9c6821276463ae3a
Gerrit-Change-Number: 9201
Gerrit-PatchSet: 1
Gerrit-Owner: Matthew Fredrickson <creslin at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180619/6ebb399d/attachment.html>


More information about the asterisk-code-review mailing list