AllStarLink / app_rpt

Refactoring and upgrade of AllStarLink's app_rpt, etc.
3 stars 2 forks source link

radio-tune-menu.c compile error #314

Closed tsawyer closed 2 months ago

tsawyer commented 2 months ago

One production attempt upgrade gives:

make[1]: Leaving directory '/usr/src/asterisk-20.1.0/menuselect'
   [CPP] simpleusb-tune-menu.c -> simpleusb-tune-menu.i
   [CCi] simpleusb-tune-menu.i -> simpleusb-tune-menu.o
   [LD] simpleusb-tune-menu.o -> simpleusb-tune-menu
   [CPP] radio-tune-menu.c -> radio-tune-menu.i
   [CCi] radio-tune-menu.i -> radio-tune-menu.o
radio-tune-menu.c: In function ‘menu_select_value’:
radio-tune-menu.c:775:10: error: format not a string literal and no format arguments [-Werror=format-security]
  775 |   printf(str);
      |          ^~~
cc1: all warnings being treated as errors
make[1]: *** [/usr/src/asterisk-20.1.0/Makefile.rules:150: radio-tune-menu.o] Error 1
make: *** [Makefile:399: utils] Error 2
InterLinked1 commented 2 months ago

Looks like that was caused by the last commit: https://github.com/AllStarLink/app_rpt/commit/7bee59dba1be80ccbebecd921601ace63e154e72#diff-b71936b109832880d4b4d82f2a2282eee22b07b5625b3cf084def92abdba946cR775

Which platform are you compiling on? I'm curious why the Debian CI didn't fail when building this.

tsawyer commented 2 months ago
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
InterLinked1 commented 2 months ago

Here's a patch that should resolve that issue:

diff --git a/utils/radio-tune-menu.c b/utils/radio-tune-menu.c
index 6393ab2..23c5f74 100644
--- a/utils/radio-tune-menu.c
+++ b/utils/radio-tune-menu.c
@@ -767,12 +767,12 @@ static void menu_swapusb(void)
 {
        char str[100];
        int i;
-
+
        printf("\nPlease select from the following methods for %s:\n", value_name);
-
+
        for (i = 0; i < max_items; i++) {
                snprintf(str, sizeof(str) - 1, "%d) %s %s\n", i + 1, items[i], selection == i ? "- Current" : "");
-               printf(str);
+               printf("%s", str);
        }

        printf("Select new %s or C/R for current): ", value_name);

That said, the snprintf + printf combo seems unnecessary to me.

tsawyer commented 2 months ago

Directions to apply this please.

root@Angel-ASL3:/usr/src/app_rpt# patch tune-patch.diff /usr/src/app_rpt/utils/radio-tune-menu.c
patch: **** Only garbage was found in the patch input.

root@Angel-ASL3:/usr/src/app_rpt# cat tune-patch.diff
diff --git a/utils/radio-tune-menu.c b/utils/radio-tune-menu.c
index 6393ab2..23c5f74 100644
--- a/utils/radio-tune-menu.c
+++ b/utils/radio-tune-menu.c
@@ -767,12 +767,12 @@ static void menu_swapusb(void)
 {
        char str[100];
        int i;
-
+
        printf("\nPlease select from the following methods for %s:\n", value_name);
-
+
        for (i = 0; i < max_items; i++) {
                snprintf(str, sizeof(str) - 1, "%d) %s %s\n", i + 1, items[i], selection == i ? "- Current" : "");
-               printf(str);
+               printf("%s", str);
        }

        printf("Select new %s or C/R for current): ", value_name);
tsawyer commented 2 months ago
patch utils/radio-tune-menu.c tune-patch.diff
patching file utils/radio-tune-menu.c
Hunk #1 FAILED at 767.
1 out of 1 hunk FAILED -- saving rejects to file utils/radio-tune-menu.c.rej
cat utils/radio-tune-menu.c.rej
--- radio-tune-menu.c
+++ radio-tune-menu.c
@@ -767,12 +767,12 @@ static void menu_swapusb(void)
 {
        char str[100];
        int i;
-
+
        printf("\nPlease select from the following methods for %s:\n", value_name);
-
+
        for (i = 0; i < max_items; i++) {
                snprintf(str, sizeof(str) - 1, "%d) %s %s\n", i + 1, items[i], selection == i ? "- Current" : "");
-               printf(str);
+               printf("%s", str);
        }

        printf("Select new %s or C/R for current): ", value_name);
InterLinked1 commented 2 months ago
patch utils/radio-tune-menu.c tune-patch.diff
patching file utils/radio-tune-menu.c
Hunk #1 FAILED at 767.
1 out of 1 hunk FAILED -- saving rejects to file utils/radio-tune-menu.c.rej
cat utils/radio-tune-menu.c.rej
--- radio-tune-menu.c
+++ radio-tune-menu.c
@@ -767,12 +767,12 @@ static void menu_swapusb(void)
 {
        char str[100];
        int i;
-
+
        printf("\nPlease select from the following methods for %s:\n", value_name);
-
+
        for (i = 0; i < max_items; i++) {
                snprintf(str, sizeof(str) - 1, "%d) %s %s\n", i + 1, items[i], selection == i ? "- Current" : "");
-               printf(str);
+               printf("%s", str);
        }

        printf("Select new %s or C/R for current): ", value_name);

You could just manually apply the change to the file, it's only that one line with the printf that's different.

tsawyer commented 2 months ago

Got it. Thank you. I'll leave this open until source is corrected.