[Reproducible-commits] [dpkg] 11/30: dselect: Do not use fixed size strings for menu entries

Mattia Rizzolo mattia at debian.org
Mon May 9 09:02:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 58876fceaf5de97a2ae609ba023d69445d6b0b41
Author: Guillem Jover <guillem at debian.org>
Date:   Fri May 6 01:17:13 2016 +0200

    dselect: Do not use fixed size strings for menu entries
---
 debian/changelog  |  1 +
 dselect/main.cc   | 15 ++++++++-------
 dselect/method.cc |  5 +----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fb35d99..24a203d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ dpkg (1.18.7) UNRELEASED; urgency=medium
     many cases could cause confusing truncation of long messages. Use heap
     allocated formatted strings instead:
     - In start-stop-daemon to report what to stop.
+    - In dselect to print main and access methods menu entries.
   * Perl modules:
     - Relax dependency restrictions parsing to allow again sloppy spaces
       around versions, architectures and profile restrictions.
diff --git a/dselect/main.cc b/dselect/main.cc
index 6f6864d..9146b22 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -394,9 +394,10 @@ urqresult urq_list(void) {
 static void
 dme(int i, int so)
 {
-  char buf[120];
   const menuentry *me= &menuentries[i];
-  sprintf(buf," %c %d. %-11.11s %-80.80s ",
+
+  varbuf buf;
+  buf.fmt(" %c %d. %-11.11s %-80.80s ",
           so ? '*' : ' ', i,
           gettext(me->option),
           gettext(me->menuent));
@@ -405,24 +406,24 @@ dme(int i, int so)
   getmaxyx(stdscr,y,x);
 
   attrset(so ? A_REVERSE : A_NORMAL);
-  mvaddnstr(i+2,0, buf,x-1);
+  mvaddnstr(i + 2, 0, buf.string(), x - 1);
   attrset(A_NORMAL);
 }
 
 static int
 refreshmenu(void)
 {
-  char buf[2048];
-
   curseson(); cbreak(); noecho(); nonl(); keypad(stdscr,TRUE);
 
   int x, y DPKG_ATTR_UNUSED;
   getmaxyx(stdscr,y,x);
 
+  varbuf buf;
+  buf.fmt(gettext(programdesc), DSELECT, PACKAGE_RELEASE);
+
   clear();
   attrset(A_BOLD);
-  sprintf(buf, gettext(programdesc), DSELECT, PACKAGE_RELEASE);
-  mvaddnstr(0,0,buf,x-1);
+  mvaddnstr(0, 0, buf.string(), x - 1);
 
   attrset(A_NORMAL);
   const struct menuentry *mep; int i;
diff --git a/dselect/method.cc b/dselect/method.cc
index 5bcf7de..d7d155e 100644
--- a/dselect/method.cc
+++ b/dselect/method.cc
@@ -59,12 +59,9 @@ static int methlockfd= -1;
 static void
 sthfailed(const char * reasoning)
 {
-  char buf[2048];
-
   curseson();
   clear();
-  sprintf(buf,_("\n\n%s: %s\n"),DSELECT,reasoning);
-  addstr(buf);
+  printw(_("\n\n%s: %s\n"), DSELECT, reasoning);
   attrset(A_BOLD);
   addstr(_("\nPress <enter> to continue."));
   attrset(A_NORMAL);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list