1Subject: [PATCH] idn: fix printf() format security warnings
2MIME-Version: 1.0
3Content-Type: text/plain; charset=UTF-8
4Content-Transfer-Encoding: 8bit
5
6| ../../libidn-1.32/src/idn.c: In function 'main':
7| ../../libidn-1.32/src/idn.c:172:7: error: format not a string literal and no format arguments [-Werror=format-security]
8|        error (0, 0, _("only one of -s, -e, -d, -a, -u or -n can be specified"));
9|        ^~~~~
10| ../../libidn-1.32/src/idn.c:187:5: error: format not a string literal and no format arguments [-Werror=format-security]
11|      fprintf (stderr, _("Type each input string on a line by itself, "
12|      ^~~~~~~
13| ../../libidn-1.32/src/idn.c:202:4: error: format not a string literal and no format arguments [-Werror=format-security]
14|     error (EXIT_FAILURE, errno, _("input error"));
15|     ^~~~~
16| ../../libidn-1.32/src/idn.c:220:8: error: format not a string literal and no format arguments [-Werror=format-security]
17|         _("could not convert from UTF-8 to UCS-4"));
18|         ^
19| ../../libidn-1.32/src/idn.c:245:8: error: format not a string literal and no format arguments [-Werror=format-security]
20|         _("could not convert from UTF-8 to UCS-4"));
21|         ^
22| ../../libidn-1.32/src/idn.c:281:6: error: format not a string literal and no format arguments [-Werror=format-security]
23|       _("could not convert from UTF-8 to UCS-4"));
24|       ^
25| ../../libidn-1.32/src/idn.c:340:6: error: format not a string literal and no format arguments [-Werror=format-security]
26|       _("could not convert from UCS-4 to UTF-8"));
27|       ^
28| ../../libidn-1.32/src/idn.c:364:6: error: format not a string literal and no format arguments [-Werror=format-security]
29|       _("could not convert from UCS-4 to UTF-8"));
30|       ^
31| ../../libidn-1.32/src/idn.c:442:8: error: format not a string literal and no format arguments [-Werror=format-security]
32|         _("could not convert from UCS-4 to UTF-8"));
33|         ^
34| ../../libidn-1.32/src/idn.c:498:6: error: format not a string literal and no format arguments [-Werror=format-security]
35|       _("could not convert from UTF-8 to UCS-4"));
36|       ^
37| ../../libidn-1.32/src/idn.c:527:5: error: format not a string literal and no format arguments [-Werror=format-security]
38|      _("could not convert from UTF-8 to UCS-4"));
39|      ^
40| ../../libidn-1.32/src/idn.c:540:6: error: format not a string literal and no format arguments [-Werror=format-security]
41|       error (EXIT_FAILURE, 0, _("could not do NFKC normalization"));
42|       ^~~~~
43| ../../libidn-1.32/src/idn.c:551:5: error: format not a string literal and no format arguments [-Werror=format-security]
44|      _("could not convert from UTF-8 to UCS-4"));
45|      ^
46
47Signed-off-by: André Draszik <adraszik@tycoint.com>
48Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com>
49
50Upstream-Status: Pending
51
52---
53 src/idn.c | 27 ++++++++++++++-------------
54 1 file changed, 14 insertions(+), 13 deletions(-)
55
56diff --git a/src/idn.c b/src/idn.c
57index f2fee11..c6e5caa 100644
58--- a/src/idn.c
59+++ b/src/idn.c
60@@ -169,7 +169,7 @@ main (int argc, char *argv[])
61       (args_info.idna_to_unicode_given ? 1 : 0) +
62       (args_info.nfkc_given ? 1 : 0) != 1)
63     {
64-      error (0, 0,
65+      error (0, 0, "%s",
66 	     _("only one of -s, -e, -d, -a, -u or -n can be specified"));
67       usage (EXIT_FAILURE);
68     }
69@@ -183,7 +183,7 @@ main (int argc, char *argv[])
70
71   if (!args_info.quiet_given
72       && args_info.inputs_num == 0 && isatty (fileno (stdin)))
73-    fprintf (stderr, _("Type each input string on a line by itself, "
74+    fprintf (stderr, "%s", _("Type each input string on a line by itself, "
75 		       "terminated by a newline character.\n"));
76
77   do
78@@ -195,7 +195,7 @@ main (int argc, char *argv[])
79 	  if (feof (stdin))
80 	    break;
81
82-	  error (EXIT_FAILURE, errno, _("input error"));
83+	  error (EXIT_FAILURE, errno, "%s", _("input error"));
84 	}
85
86       if (strlen (line) > 0)
87@@ -213,7 +213,7 @@ main (int argc, char *argv[])
88 	  if (!q)
89 	    {
90 	      free (p);
91-	      error (EXIT_FAILURE, 0,
92+	      error (EXIT_FAILURE, 0, "%s",
93 		     _("could not convert from UTF-8 to UCS-4"));
94 	    }
95
96@@ -238,7 +238,7 @@ main (int argc, char *argv[])
97 	  if (!q)
98 	    {
99 	      free (r);
100-	      error (EXIT_FAILURE, 0,
101+	      error (EXIT_FAILURE, 0, "%s",
102 		     _("could not convert from UTF-8 to UCS-4"));
103 	    }
104
105@@ -275,7 +275,7 @@ main (int argc, char *argv[])
106 	  q = stringprep_utf8_to_ucs4 (p, -1, &len);
107 	  free (p);
108 	  if (!q)
109-	    error (EXIT_FAILURE, 0,
110+	    error (EXIT_FAILURE, 0, "%s",
111 		   _("could not convert from UTF-8 to UCS-4"));
112
113 	  if (args_info.debug_given)
114@@ -334,7 +334,7 @@ main (int argc, char *argv[])
115 	  r = stringprep_ucs4_to_utf8 (q, -1, NULL, NULL);
116 	  free (q);
117 	  if (!r)
118-	    error (EXIT_FAILURE, 0,
119+	    error (EXIT_FAILURE, 0, "%s",
120 		   _("could not convert from UCS-4 to UTF-8"));
121
122 	  p = stringprep_utf8_to_locale (r);
123@@ -358,7 +358,7 @@ main (int argc, char *argv[])
124 	  q = stringprep_utf8_to_ucs4 (p, -1, NULL);
125 	  free (p);
126 	  if (!q)
127-	    error (EXIT_FAILURE, 0,
128+	    error (EXIT_FAILURE, 0, "%s",
129 		   _("could not convert from UCS-4 to UTF-8"));
130
131 	  if (args_info.debug_given)
132@@ -436,7 +436,7 @@ main (int argc, char *argv[])
133 	  if (!q)
134 	    {
135 	      free (p);
136-	      error (EXIT_FAILURE, 0,
137+	      error (EXIT_FAILURE, 0, "%s",
138 		     _("could not convert from UCS-4 to UTF-8"));
139 	    }
140
141@@ -492,7 +492,7 @@ main (int argc, char *argv[])
142 	  r = stringprep_ucs4_to_utf8 (q, -1, NULL, NULL);
143 	  free (q);
144 	  if (!r)
145-	    error (EXIT_FAILURE, 0,
146+	    error (EXIT_FAILURE, 0, "%s",
147 		   _("could not convert from UTF-8 to UCS-4"));
148
149 	  p = stringprep_utf8_to_locale (r);
150@@ -521,7 +521,7 @@ main (int argc, char *argv[])
151 	      if (!q)
152 		{
153 		  free (p);
154-		  error (EXIT_FAILURE, 0,
155+		  error (EXIT_FAILURE, 0, "%s",
156 			 _("could not convert from UTF-8 to UCS-4"));
157 		}
158
159@@ -535,7 +535,8 @@ main (int argc, char *argv[])
160 	  r = stringprep_utf8_nfkc_normalize (p, -1);
161 	  free (p);
162 	  if (!r)
163-	    error (EXIT_FAILURE, 0, _("could not do NFKC normalization"));
164+	    error (EXIT_FAILURE, 0, "%s",
165+		   _("could not do NFKC normalization"));
166
167 	  if (args_info.debug_given)
168 	    {
169@@ -545,7 +546,7 @@ main (int argc, char *argv[])
170 	      if (!q)
171 		{
172 		  free (r);
173-		  error (EXIT_FAILURE, 0,
174+		  error (EXIT_FAILURE, 0, "%s",
175 			 _("could not convert from UTF-8 to UCS-4"));
176 		}
177
178--
1792.25.1
180
181