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

Joshua Colp asteriskteam at digium.com
Thu Jun 21 04:24:46 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9191 )

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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
  George Joseph: Looks good to me, approved



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/9191
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2213dcb454aff26457e2e4cc9c6821276463ae3a
Gerrit-Change-Number: 9191
Gerrit-PatchSet: 3
Gerrit-Owner: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180621/c264eed6/attachment.html>


More information about the asterisk-code-review mailing list