commit:     d8ea4b37177694ee57c94223f13c1f8e92c4cc8c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 16:12:01 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Feb 12 16:12:01 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8ea4b37

net-misc/smbc: fix Modern C issue, fix -Wformat-security

Not fixed the nested functions though.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 net-misc/smbc/files/0001-Fix-signal-handlers.patch | 104 ++++++++++++++
 .../smbc/files/0002-Fix-Wformat-security.patch     | 150 +++++++++++++++++++++
 .../{smbc-1.2.2-r3.ebuild => smbc-1.2.2-r4.ebuild} |  15 ++-
 3 files changed, 264 insertions(+), 5 deletions(-)

diff --git a/net-misc/smbc/files/0001-Fix-signal-handlers.patch 
b/net-misc/smbc/files/0001-Fix-signal-handlers.patch
new file mode 100644
index 000000000000..3e4ece3bef0c
--- /dev/null
+++ b/net-misc/smbc/files/0001-Fix-signal-handlers.patch
@@ -0,0 +1,104 @@
+From 1d9dc54aea5a36aa43ce3bb5d5a013121fbd25ab Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Wed, 12 Feb 2025 16:04:02 +0000
+Subject: [PATCH 1/2] Fix signal handlers
+
+They need to take an argument but we don't use it.
+
+Signed-off-by: Sam James <[email protected]>
+---
+ src/smbc.c | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/src/smbc.c b/src/smbc.c
+index 41a3d28..86349d0 100644
+--- a/src/smbc.c
++++ b/src/smbc.c
+@@ -251,9 +251,9 @@ void RwinRedrawWithData();
+ void RcompareTwoIndexFile(int RfdNew, int RfdOld, int RfdMessage);
+ int RtryDownloadUpload();
+ void RtryLockFileAndCreateIndexFile();
+-void RsigAlarm();
+-void RsigTerm();
+-void RsigSEGV();
++void RsigAlarm(int unused);
++void RsigTerm(int unused);
++void RsigSEGV(int unused);
+ char *RgetSmallPath(char *Rhost);
+ 
+ //-------------------------------------------------------------
+@@ -1196,7 +1196,7 @@ RmanageList()
+     {
+       if (!RdownloadListTmp) {
+         RDBG("smbc: RmanageList RpaintList - error expected next record\n"); 
+-        RsigTerm();
++        RsigTerm(0);
+       }
+       mvwhline(RwinCol1, ++Rk, 0, 32, 1);
+       mvwhline(RwinCol2, Rk, 0, 32, 1);
+@@ -1354,7 +1354,7 @@ RmanageList()
+   }
+ 
+   void 
+-  RsigAlarmManageWindow() 
++  RsigAlarmManageWindow(int unused) 
+   {
+     RDBG("RmanageList : RsigAlarmManageWindow alarm\n");
+     RdoWindowResizeDownloadList();
+@@ -5543,7 +5543,7 @@ RcreateFindListIndex(int Isave, char *Igroup, char 
*Ihost, char *Ipath, char *Id
+ }
+ 
+ void 
+-RsigTerm()
++RsigTerm(int unused)
+ {
+   int Ri;
+ 
+@@ -5602,7 +5602,7 @@ RsigTerm()
+ }
+ 
+ void 
+-RsigCHLD()
++RsigCHLD(int unused)
+ {
+   waitpid(RchildId, NULL, WNOHANG);
+ }
+@@ -6393,7 +6393,7 @@ RsendWinpopupInput(char *RgroupInput)
+ }
+ 
+ void 
+-RsigSEGV()
++RsigSEGV(int unused)
+ {
+   int Rres = errno;
+ 
+@@ -6404,7 +6404,7 @@ RsigSEGV()
+   RDBG("\n");
+   RDBG("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+   Rerror = 1;
+-  RsigTerm();
++  RsigTerm(0);
+   exit(Rres);
+ }
+ 
+@@ -6819,7 +6819,7 @@ RtryDownloadUpload()
+ }
+ 
+ void 
+-RsigAlarm()
++RsigAlarm(int unused)
+ {
+   char RinsertChar = 1;
+ 
+@@ -8220,7 +8220,7 @@ RDBG("smbc: main 100\n");
+  Rfree(RfileNameMessagePrim);
+  Rfree(RsmbcLockFile);
+  RDBG("----stop 2----\n");
+- RsigTerm();
++ RsigTerm(0);
+  RfreeDebug();
+  return(0);
+ }
+-- 
+2.48.1
+

diff --git a/net-misc/smbc/files/0002-Fix-Wformat-security.patch 
b/net-misc/smbc/files/0002-Fix-Wformat-security.patch
new file mode 100644
index 000000000000..357856b0516d
--- /dev/null
+++ b/net-misc/smbc/files/0002-Fix-Wformat-security.patch
@@ -0,0 +1,150 @@
+From 0f514db1868a34839a673257543a00383a5183df Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Wed, 12 Feb 2025 16:07:23 +0000
+Subject: [PATCH 2/2] Fix -Wformat-security
+
+Signed-off-by: Sam James <[email protected]>
+---
+ src/dulist.c |  2 +-
+ src/fnet.c   | 14 +++++++-------
+ src/smbc.c   | 16 ++++++++--------
+ 3 files changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/src/dulist.c b/src/dulist.c
+index 23c0024..c353acc 100644
+--- a/src/dulist.c
++++ b/src/dulist.c
+@@ -200,7 +200,7 @@ RShowAllItemsFromDUlist(int RnrDulist)
+         Rstraddtoend(&RstrT, "/");
+         Rstraddtoend(&RstrT, Rdls->filename);
+         Rstraddtoend(&RstrT, "\n");
+-        printf(to_scr(RstrT));
++        printf("%s", to_scr(RstrT));
+         Rfree(RstrT);
+         RfreeOneTTdownloadAndGoToFirst(&Rdls);
+       }
+diff --git a/src/fnet.c b/src/fnet.c
+index cc401af..7c35d2e 100644
+--- a/src/fnet.c
++++ b/src/fnet.c
+@@ -184,7 +184,7 @@ void
+ refreshw(WINDOW *win, char *buf)
+ {
+   werase(win);
+-  mvwprintw(win, 1, 1, buf);
++  mvwprintw(win, 1, 1, "%s", buf);
+ }
+ 
+ int 
+@@ -407,7 +407,7 @@ RmvwprintwCenter(WINDOW *win, int i, char *str)
+   int y, x;
+ 
+   getmaxyx(win, y, x);
+-  mvwprintw(win, i, x/2-strlen(str)/2, str);
++  mvwprintw(win, i, x/2-strlen(str)/2, "%s", str);
+   wrefresh(win);
+ }
+ 
+@@ -427,7 +427,7 @@ refreshTxtInWin(WINDOW *win, int y, int x, char *buf, int 
winSize, int startidx,
+     wattron(win, COLOR_PAIR(colorPair));
+   mvwhline(win, y, x+xDelta, ' ', winSize-xDelta);
+   wattron(win, attr);
+-  mvwprintw(win, y, x+xDelta, str+startidx);
++  mvwprintw(win, y, x+xDelta, "%s", str+startidx);
+   wattroff(win, attr);
+   if (colorPair != -1) 
+     wattroff(win, COLOR_PAIR(colorPair));
+@@ -474,7 +474,7 @@ refreshTxtInWinCursor(WINDOW *win, int y, int x, char 
*buf, int winSize, int sta
+   Rstr = strdup(Rbuf+startidx);
+   Rstr[xCursor-startidx] = 0;
+   RDBG("fnet refreshTxtInWinCursor 1: Rstr = \""); RDBG(Rstr); RDBG("\"\n");
+-  mvwprintw(win, y, x, Rstr);
++  mvwprintw(win, y, x, "%s", Rstr);
+   Rprinted = strlen(Rstr);
+   Rfree(Rstr);
+    
+@@ -500,7 +500,7 @@ refreshTxtInWinCursor(WINDOW *win, int y, int x, char 
*buf, int winSize, int sta
+     RDBG("fnet refreshTxtInWinCursor 23\n");
+   }
+   RDBG("fnet refreshTxtInWinCursor 29: Rstr = \""); RDBG(Rstr); RDBG("\"\n");
+-  mvwprintw(win, y, x+Rprinted, Rstr);
++  mvwprintw(win, y, x+Rprinted, "%s", Rstr);
+   Rfree(Rstr);
+   wattroff(win, A_REVERSE);
+   Rprinted++;
+@@ -514,7 +514,7 @@ refreshTxtInWinCursor(WINDOW *win, int y, int x, char 
*buf, int winSize, int sta
+     if (winSize-Rprinted < strlen(Rstr))
+        Rstr[winSize-Rprinted] = 0;
+     RDBG("fnet refreshTxtInWinCursor 3: Rstr = \""); RDBG(Rstr); RDBG("\"\n");
+-    mvwprintw(win, y, x+Rprinted, Rstr);
++    mvwprintw(win, y, x+Rprinted, "%s", Rstr);
+     Rfree(Rstr);
+   }
+ 
+@@ -929,7 +929,7 @@ Rmvwprintw(WINDOW *win, int y, int x, const char *fmt)
+   }
+   RDBG("fnet: RmvwprintwAddPercent fmt = |"); RDBG((char *)fmt); RDBG("|\n");
+   RDBG("fnet: RmvwprintwAddPercent Rc1 = |"); RDBG(Rc1); RDBG("|\n");
+-  mvwprintw(win, y, x, Rc1);
++  mvwprintw(win, y, x, "%s", Rc1);
+   Ri = strlen(Rc1);
+   Rfree(Rc1);
+   RDBG("fnet: RmvwprintwAddPercent end\n");
+diff --git a/src/smbc.c b/src/smbc.c
+index 86349d0..d2fbb07 100644
+--- a/src/smbc.c
++++ b/src/smbc.c
+@@ -2174,7 +2174,7 @@ RwinRedraw()
+   mvwhline(RwinLeftTop, 0, 0, 0, RxHalf-2);
+   mvwhline(RwinRightTop, 0, 0, 0, RxHalf-2);
+   mvwprintw(RwinHead, 0, 0,"Samba Commander %s", VERSION);
+-  mvwprintw(RwinHead, 0, RmainWinX-Rstrlen(Rm108), Rm108);
++  mvwprintw(RwinHead, 0, RmainWinX-Rstrlen(Rm108), "%s", Rm108);
+   mvwhline(RwinLeft, 2, 1, 0, RxHalf-2);
+   mvwhline(RwinLeft, 2, 1, 0, RxHalf-2);
+   mvwvline(RwinLeftList, 0, 1, 0, RmainWinY-6);
+@@ -3615,9 +3615,9 @@ RreadRcfile()
+   Rstraddtoend(&Rfile, "/.smbc/smbcrc");
+   if (access(Rfile, F_OK) != 0) 
+   {
+-    printf(Rm242, Rfile);
+-    printf(Rm243);
+-    printf(Rm244);
++    printf("%s", Rm242, Rfile);
++    printf("%s", Rm243);
++    printf("%s", Rm244);
+     return;
+   }
+   Rfd = open(Rfile, O_RDONLY);
+@@ -5575,8 +5575,8 @@ RsigTerm(int unused)
+   endwin();
+   if (!Ri) 
+   {
+-    printf(Rm156);
+-    printf(Rm157);
++    printf("%s", Rm156);
++    printf("%s", Rm157);
+   }
+   if ((RmainWinX < 80) || (RmainWinY < 25)) 
+     printf(Rm158, RmainWinX, RmainWinY);
+@@ -5589,7 +5589,7 @@ RsigTerm(int unused)
+   if (Rerror) 
+   {
+     printf("**********************************************************\n");
+-    printf(Rm159);
++    printf("%s", Rm159);
+     printf("**********************************************************\n");
+   }
+ 
+@@ -6990,7 +6990,7 @@ main(int argc,char *argv[])
+  {
+    fprintf(stderr, Rm175, errno);
+    if (errno == 2) 
+-     fprintf(stderr, Rm176);
++     fprintf(stderr, "%s", Rm176);
+    exit(0);
+  }
+ 
+-- 
+2.48.1
+

diff --git a/net-misc/smbc/smbc-1.2.2-r3.ebuild 
b/net-misc/smbc/smbc-1.2.2-r4.ebuild
similarity index 78%
rename from net-misc/smbc/smbc-1.2.2-r3.ebuild
rename to net-misc/smbc/smbc-1.2.2-r4.ebuild
index 67bb75f96311..6799dc8a4a58 100644
--- a/net-misc/smbc/smbc-1.2.2-r3.ebuild
+++ b/net-misc/smbc/smbc-1.2.2-r4.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -15,17 +15,22 @@ KEYWORDS="~amd64 ~ppc ~x86"
 IUSE="nls debug"
 
 BDEPEND="virtual/pkgconfig"
-DEPEND="dev-libs/popt
+DEPEND="
+       dev-libs/popt
        net-fs/samba
-       sys-libs/ncurses
-       nls? ( sys-devel/gettext )"
+       sys-libs/ncurses:=
+       nls? ( sys-devel/gettext )
+"
 RDEPEND="${DEPEND}"
 
-PATCHES=( "${FILESDIR}"/${P}-cflags.patch
+PATCHES=(
+       "${FILESDIR}"/${P}-cflags.patch
        "${FILESDIR}"/${P}-size_t.patch
        "${FILESDIR}"/${P}-samba4-includes.patch
        "${FILESDIR}"/${P}-multiple-definitions-gcc10.patch
        "${FILESDIR}"/${P}-tinfo.patch
+       "${FILESDIR}"/0001-Fix-signal-handlers.patch
+       "${FILESDIR}"/0002-Fix-Wformat-security.patch
 )
 
 src_prepare() {

Reply via email to