Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh Don't use non-literal format strings.



details:   https://anonhg.NetBSD.org/src/rev/3c741fe5bafe
branches:  trunk
changeset: 770428:3c741fe5bafe
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sun Oct 16 17:12:11 2011 +0000

description:
Don't use non-literal format strings.

diffstat:

 bin/ksh/Makefile |   4 +---
 bin/ksh/c_ksh.c  |  16 ++++++++--------
 bin/ksh/exec.c   |   6 +++---
 bin/ksh/expr.c   |   6 +++---
 bin/ksh/jobs.c   |   6 +++---
 bin/ksh/lex.c    |   6 +++---
 bin/ksh/main.c   |   8 ++++----
 bin/ksh/misc.c   |  12 ++++++------
 bin/ksh/var.c    |   8 ++++----
 9 files changed, 35 insertions(+), 37 deletions(-)

diffs (truncated from 318 to 300 lines):

diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/Makefile
--- a/bin/ksh/Makefile  Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/Makefile  Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.29 2011/08/14 10:40:25 christos Exp $
+#      $NetBSD: Makefile,v 1.30 2011/10/16 17:12:11 joerg Exp $
 
 WARNS=3
 
@@ -47,6 +47,4 @@
        ${HOST_SH} $(.CURDIR)/mkman ksh $(.CURDIR)/ksh.Man >ksh.1.tmp \
            && mv ksh.1.tmp ksh.1
 
-CWARNFLAGS.clang+=     -Wno-format-security
-
 .include <bsd.prog.mk>
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/c_ksh.c
--- a/bin/ksh/c_ksh.c   Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/c_ksh.c   Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: c_ksh.c,v 1.17 2011/08/31 16:24:54 plunky Exp $        */
+/*     $NetBSD: c_ksh.c,v 1.18 2011/10/16 17:12:11 joerg Exp $ */
 
 /*
  * built-in Korn commands: c_*
@@ -6,7 +6,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: c_ksh.c,v 1.17 2011/08/31 16:24:54 plunky Exp $");
+__RCSID("$NetBSD: c_ksh.c,v 1.18 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 #include "sh.h"
@@ -573,7 +573,7 @@
                        break;
                }
                if (vflag || !ret)
-                       shprintf(newline);
+                       shprintf("%s", newline);
        }
        return ret;
 }
@@ -873,7 +873,7 @@
                                else
                                    print_value_quoted(s);
                            }
-                           shprintf(newline);
+                           shprintf("%s", newline);
                        }
                        /* Only report first `element' of an array with
                         * no set elements.
@@ -964,7 +964,7 @@
                                        shf_putc('=', shl_stdout);
                                        print_value_quoted(ap->val.s);
                                }
-                               shprintf(newline);
+                               shprintf("%s", newline);
                        }
        }
 
@@ -988,7 +988,7 @@
                                        shf_putc('=', shl_stdout);
                                        print_value_quoted(ap->val.s);
                                }
-                               shprintf(newline);
+                               shprintf("%s", newline);
                        } else {
                                shprintf("%s alias not found\n", alias);
                                rv = 1;
@@ -1236,7 +1236,7 @@
 "usage: kill [ -s signame | -signum | -signame ] {pid|job}...\n\
        kill -l [exit_status]\n"
                        );
-               bi_errorf(null);
+               bi_errorf("%s", null);
                return 1;
        }
 
@@ -1257,7 +1257,7 @@
                        for (i = 1; i < SIGNALS; i++, p = space)
                                if (sigtraps[i].name)
                                        shprintf("%s%s", p, sigtraps[i].name);
-                       shprintf(newline);
+                       shprintf("%s", newline);
                } else {
                        int w, si;
                        int mess_width;
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/exec.c
--- a/bin/ksh/exec.c    Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/exec.c    Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec.c,v 1.13 2006/04/24 19:58:20 christos Exp $       */
+/*     $NetBSD: exec.c,v 1.14 2011/10/16 17:12:11 joerg Exp $  */
 
 /*
  * execute command tree
@@ -6,7 +6,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: exec.c,v 1.13 2006/04/24 19:58:20 christos Exp $");
+__RCSID("$NetBSD: exec.c,v 1.14 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 
@@ -151,7 +151,7 @@
                                 */
                                if (tp && tp->type == CSHELL
                                    && (tp->flag & SPEC_BI))
-                                       errorf(null);
+                                       errorf("%s", null);
                                /* Deal with FERREXIT, quitenv(), etc. */
                                goto Break;
                        }
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/expr.c
--- a/bin/ksh/expr.c    Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/expr.c    Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expr.c,v 1.8 2005/06/26 19:09:00 christos Exp $        */
+/*     $NetBSD: expr.c,v 1.9 2011/10/16 17:12:11 joerg Exp $   */
 
 /*
  * Korn expression evaluation
@@ -9,7 +9,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: expr.c,v 1.8 2005/06/26 19:09:00 christos Exp $");
+__RCSID("$NetBSD: expr.c,v 1.9 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 
@@ -193,7 +193,7 @@
                if (i == LAEXPR) {
                        if (error_ok == KSH_RETURN_ERROR)
                                return 0;
-                       errorf(null);
+                       errorf("%s", null);
                }
                unwind(i);
                /*NOTREACHED*/
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/jobs.c
--- a/bin/ksh/jobs.c    Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/jobs.c    Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: jobs.c,v 1.9 2006/02/25 00:58:34 wiz Exp $     */
+/*     $NetBSD: jobs.c,v 1.10 2011/10/16 17:12:11 joerg Exp $  */
 
 /*
  * Process and job control
@@ -26,7 +26,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: jobs.c,v 1.9 2006/02/25 00:58:34 wiz Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.10 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 
@@ -900,7 +900,7 @@
                }
                shprintf("%s%s", p->command, p->next ? "| " : null);
        }
-       shprintf(newline);
+       shprintf("%s", newline);
        shf_flush(shl_stdout);
        if (running)
                j->state = PRUNNING;
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/lex.c
--- a/bin/ksh/lex.c     Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/lex.c     Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lex.c,v 1.14 2011/01/23 17:15:15 hauke Exp $   */
+/*     $NetBSD: lex.c,v 1.15 2011/10/16 17:12:11 joerg Exp $   */
 
 /*
  * lexical analysis and source input
@@ -6,7 +6,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: lex.c,v 1.14 2011/01/23 17:15:15 hauke Exp $");
+__RCSID("$NetBSD: lex.c,v 1.15 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 
@@ -861,7 +861,7 @@
        SH_VA_START(va, fmt);
        shf_vfprintf(shl_out, fmt, va);
        va_end(va);
-       errorf(null);
+       errorf("%s", null);
 }
 
 /*
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/main.c
--- a/bin/ksh/main.c    Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/main.c    Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.14 2007/06/24 18:00:49 christos Exp $       */
+/*     $NetBSD: main.c,v 1.15 2011/10/16 17:12:11 joerg Exp $  */
 
 /*
  * startup, main loop, environments and error handling
@@ -7,7 +7,7 @@
 #include <locale.h>
 
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.14 2007/06/24 18:00:49 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.15 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 
@@ -565,7 +565,7 @@
                  case LSHELL:
                        if (interactive) {
                                if (i == LINTR)
-                                       shellf(newline);
+                                       shellf("%s", newline);
                                /* Reset any eof that was read as part of a
                                 * multiline command.
                                 */
@@ -864,6 +864,6 @@
        const char *msg;
 {
        internal_errorf(1, "alloc: %s", msg);
-       errorf(null); /* this is never executed - keeps gcc quiet */
+       errorf("%s", null); /* this is never executed - keeps gcc quiet */
        /*NOTREACHED*/
 }
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/misc.c
--- a/bin/ksh/misc.c    Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/misc.c    Sun Oct 16 17:12:11 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: misc.c,v 1.14 2009/10/22 15:53:19 seanb Exp $  */
+/*     $NetBSD: misc.c,v 1.15 2011/10/16 17:12:11 joerg Exp $  */
 
 /*
  * Miscellaneous functions
@@ -6,7 +6,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: misc.c,v 1.14 2009/10/22 15:53:19 seanb Exp $");
+__RCSID("$NetBSD: misc.c,v 1.15 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 
@@ -265,7 +265,7 @@
                for (i = 0; i < (int)NELEM(goptions); i++)
                        if (Flag(i) && goptions[i].name)
                                shprintf(" -o %s", goptions[i].name);
-               shprintf(newline);
+               shprintf("%s", newline);
        }
 }
 
@@ -1011,7 +1011,7 @@
                                (go->flags & GF_NONAME) ? "" : argv[0],
                                (go->flags & GF_NONAME) ? "" : ": ", c);
                        if (go->flags & GF_ERROR)
-                               bi_errorf(null);
+                               bi_errorf("%s", null);
                }
                return '?';
        }
@@ -1037,7 +1037,7 @@
                                (go->flags & GF_NONAME) ? "" : argv[0],
                                (go->flags & GF_NONAME) ? "" : ": ", c);
                        if (go->flags & GF_ERROR)
-                               bi_errorf(null);
+                               bi_errorf("%s", null);
                        return '?';
                }
                go->p = 0;
@@ -1088,7 +1088,7 @@
        }
        for (p = s; *p; p++) {
                if (*p == '\'') {
-                       shprintf("'\\'" + 1 - inquote);
+                       shprintf("%s", "'\\'" + 1 - inquote);
                        inquote = 0;
                } else {
                        if (!inquote) {
diff -r 96273ee6ef93 -r 3c741fe5bafe bin/ksh/var.c
--- a/bin/ksh/var.c     Sun Oct 16 13:43:26 2011 +0000
+++ b/bin/ksh/var.c     Sun Oct 16 17:12:11 2011 +0000
@@ -1,9 +1,9 @@
-/*     $NetBSD: var.c,v 1.16 2011/10/16 00:32:25 reed Exp $    */
+/*     $NetBSD: var.c,v 1.17 2011/10/16 17:12:11 joerg Exp $   */
 
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: var.c,v 1.16 2011/10/16 00:32:25 reed Exp $");
+__RCSID("$NetBSD: var.c,v 1.17 2011/10/16 17:12:11 joerg Exp $");
 #endif
 
 



Home | Main Index | Thread Index | Old Index