From 3d4219014ae5f5a6553423994ff5ccd1d490a6fc Mon Sep 17 00:00:00 2001
From: Rob Landley <rob@landley.net>
Date: Mon, 19 Nov 2018 10:54:26 -0600
Subject: Eduardas Meile reported "The -Werror=format-security flag is applied
 by default in Yocto 2.6 Thud release" and identified several error_exit() and
 friends that should use the _raw versions.

---
 toys/pending/fsck.c  | 2 +-
 toys/pending/getty.c | 6 ++----
 toys/pending/test.c  | 4 ++--
 toys/pending/tftp.c  | 2 +-
 toys/pending/tftpd.c | 4 ++--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c
index 723f77de..ac00bff7 100644
--- a/toys/pending/fsck.c
+++ b/toys/pending/fsck.c
@@ -223,7 +223,7 @@ static void do_fsck(struct f_sys_info *finfo)
     return;
   } else { 
     if ((pid = fork()) < 0) {
-      perror_msg(args[0]);
+      perror_msg_raw(*args);
       for (j=0;j<i;j++) free(args[i]);
       free(args);
       return; 
diff --git a/toys/pending/getty.c b/toys/pending/getty.c
index 25d04eaa..51b58962 100644
--- a/toys/pending/getty.c
+++ b/toys/pending/getty.c
@@ -278,8 +278,7 @@ static void utmp_entry(void)
         strlen("/dev/"), UT_LINESIZE);
     time((time_t *)&entry.ut_time);
     xstrncpy(entry.ut_user, "LOGIN", UT_NAMESIZE);
-    if (strlen(TT.host_str) > UT_HOSTSIZE) 
-      perror_msg(utmperr);
+    if (strlen(TT.host_str) > UT_HOSTSIZE) perror_msg_raw(utmperr);
     else xstrncpy(entry.ut_host, TT.host_str, UT_HOSTSIZE);
     setutent();
     pututline(&entry);
@@ -287,8 +286,7 @@ static void utmp_entry(void)
   }
   xstrncpy(entry.ut_line, ttyname(STDIN_FILENO) + strlen("/dev/"), UT_LINESIZE);
   xstrncpy(entry.ut_user, "LOGIN", UT_NAMESIZE);
-  if (strlen(TT.host_str) > UT_HOSTSIZE) 
-    perror_msg(utmperr);
+  if (strlen(TT.host_str) > UT_HOSTSIZE) perror_msg_raw(utmperr);
   else xstrncpy(entry.ut_host, TT.host_str, UT_HOSTSIZE);
   time((time_t *)&entry.ut_time);
   setutent();
diff --git a/toys/pending/test.c b/toys/pending/test.c
index e64ebf14..d887fc9f 100644
--- a/toys/pending/test.c
+++ b/toys/pending/test.c
@@ -149,7 +149,7 @@ int test_sub(int optb, int opte)
         if (optb + i == opte || !strcmp("-a", toys.optargs[optb + i])
             || !strcmp("-o", toys.optargs[optb + i])) break;
       }
-      if (i == 4) error_exit(err_syntax);
+      if (i == 4) error_exit_raw(err_syntax);
       expr = not ^ test_basic(optb, optb + i);
       optb += i;
     }
@@ -166,7 +166,7 @@ int test_sub(int optb, int opte)
       and = and && expr;
       optb++;
     }
-    else error_exit(err_syntax);
+    else error_exit_raw(err_syntax);
   }
 }
 
diff --git a/toys/pending/tftp.c b/toys/pending/tftp.c
index 30ebe81c..1e32fdf4 100644
--- a/toys/pending/tftp.c
+++ b/toys/pending/tftp.c
@@ -328,7 +328,7 @@ static int file_get(void)
               TFTP_ES_UNKID, TFTP_ES_EXISTS,
               TFTP_ES_UNKUSER, TFTP_ES_NEGOTIATE};
             if (rblockno && (rblockno < 9)) message = arr[rblockno - 1];
-            error_msg(message);
+            error_msg_raw(message);
         }
         else if (blockno == 1 && opcode == TFTP_OP_OACK) {
           len = mkpkt_ack(packet, 0);
diff --git a/toys/pending/tftpd.c b/toys/pending/tftpd.c
index 806326eb..9791ae41 100644
--- a/toys/pending/tftpd.c
+++ b/toys/pending/tftpd.c
@@ -77,7 +77,7 @@ static char *g_errpkt = toybuf + TFTPD_BLKSIZE;
 static void send_errpkt(struct sockaddr *dstaddr,
     socklen_t socklen, char *errmsg)
 {
-  error_msg(errmsg);
+  error_msg_raw(errmsg);
   g_errpkt[1] = TFTPD_OP_ERR;
   strcpy(g_errpkt + 4, errmsg);
   if (sendto(TT.sfd, g_errpkt, strlen(errmsg)+5, 0, dstaddr, socklen) < 0)
@@ -196,7 +196,7 @@ POLL_INPUT:
         "No such user", "Terminate transfer due to option negotiation"};
 
       if (rblockno && (rblockno < 9)) message = arr[rblockno - 1];
-      error_msg(message);
+      error_msg_raw(message);
       break; // Break the for loop.
     }
 
-- 
cgit v1.2.3