summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-10-27 18:49:25 +0000
committerguenther <guenther@openbsd.org>2013-10-27 18:49:25 +0000
commit390b7edb69e257eeb514689ee52c15ebd69cccda (patch)
tree3cc5e144428de10e41d3b69c08f6f2897d53b00a /usr.sbin
parentIf a constant string needs a name, use a static const array instead of a (diff)
downloadwireguard-openbsd-390b7edb69e257eeb514689ee52c15ebd69cccda.tar.xz
wireguard-openbsd-390b7edb69e257eeb514689ee52c15ebd69cccda.zip
If a constant string needs a name, use a static const array instead of a
pointer or non-const array, as that minimizes the symbols, maximizes the placement into read-only memory, and avoids warnings from gcc -Wformat=2 when they're used as format strings. ok deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpctl/irr_output.c6
-rw-r--r--usr.sbin/bgpctl/whois.c6
-rw-r--r--usr.sbin/httpd/src/modules/keynote/mod_keynote.c2
-rw-r--r--usr.sbin/lpr/common_source/displayq.c6
-rw-r--r--usr.sbin/pppd/options.c4
-rw-r--r--usr.sbin/tcpdump/print-bootp.c4
6 files changed, 13 insertions, 15 deletions
diff --git a/usr.sbin/bgpctl/irr_output.c b/usr.sbin/bgpctl/irr_output.c
index 3b93c32b0c6..5e06a079db4 100644
--- a/usr.sbin/bgpctl/irr_output.c
+++ b/usr.sbin/bgpctl/irr_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: irr_output.c,v 1.13 2007/03/05 17:28:21 henning Exp $ */
+/* $OpenBSD: irr_output.c,v 1.14 2013/10/27 18:49:25 guenther Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -196,7 +196,6 @@ void
print_rule(FILE *fh, struct policy_item *pi, char *sourceas,
struct irr_prefix *prefix)
{
- char *fmt = "allow quick %s %s%s%s%s%s\n";
char *peer = "any";
char *action = "";
char *dir;
@@ -240,5 +239,6 @@ print_rule(FILE *fh, struct policy_item *pi, char *sourceas,
}
}
- fprintf(fh, fmt, dir, peer, srcas[0], srcas[1], pbuf, action);
+ fprintf(fh, "allow quick %s %s%s%s%s%s\n", dir, peer,
+ srcas[0], srcas[1], pbuf, action);
}
diff --git a/usr.sbin/bgpctl/whois.c b/usr.sbin/bgpctl/whois.c
index f14d07d8ed7..1128768f327 100644
--- a/usr.sbin/bgpctl/whois.c
+++ b/usr.sbin/bgpctl/whois.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: whois.c,v 1.4 2009/09/08 15:40:25 claudio Exp $ */
+/* $OpenBSD: whois.c,v 1.5 2013/10/27 18:49:25 guenther Exp $ */
/*
* Copyright (c) 2007 Henning Brauer <henning@openbsd.org>
@@ -82,7 +82,6 @@ whois(const char *query, enum qtype qtype)
int s, r = -1, error = 0, attempt, ret;
struct addrinfo hints, *res, *ai;
const char *reason = NULL;
- char *fmt;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = 0;
@@ -137,8 +136,7 @@ whois(const char *query, enum qtype qtype)
sfw = fdopen(s, "w");
if (sfr == NULL || sfw == NULL)
err(1, "fdopen");
- fmt = "%s %s %s\r\n";
- fprintf(sfw, fmt, WHOIS_STDOPTS, qtype_opts[qtype], query);
+ fprintf(sfw, "%s %s %s\r\n", WHOIS_STDOPTS, qtype_opts[qtype], query);
fflush(sfw);
if ((ret = parse_response(sfr, qtype)) == -1)
diff --git a/usr.sbin/httpd/src/modules/keynote/mod_keynote.c b/usr.sbin/httpd/src/modules/keynote/mod_keynote.c
index cd382992a0d..4ef5ae8c3e6 100644
--- a/usr.sbin/httpd/src/modules/keynote/mod_keynote.c
+++ b/usr.sbin/httpd/src/modules/keynote/mod_keynote.c
@@ -459,7 +459,7 @@ keynote_fake_assertion(request_rec *r, int sessid, X509 *cert, EVP_PKEY *pkey, X
char *akey, *ikey, *buf, *stext, *itext;
char before[15], after[15];
char *timecomp, *timecomp2;
- char *fmt = "Authorizer: \"%s%s\"\nLicensees: \"%s%s\"\n"
+ static const char fmt[] = "Authorizer: \"%s%s\"\nLicensees: \"%s%s\"\n"
"Conditions: %s >= \"%s\" && %s <= \"%s\";\n";
if (pkey && pkey->type != EVP_PKEY_RSA && pkey->type != EVP_PKEY_DSA) {
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index 3f8dec20f19..ffc15f5fa7f 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: displayq.c,v 1.32 2012/03/04 04:05:15 fgsch Exp $ */
+/* $OpenBSD: displayq.c,v 1.33 2013/10/27 18:49:25 guenther Exp $ */
/* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */
/*
@@ -73,8 +73,8 @@ static int first; /* first file in ``files'' column? */
static int lflag; /* long output option */
static off_t totsize; /* total print job size in bytes */
-static const char *head0 = "Rank Owner Job Files";
-static const char *head1 = "Total Size\n";
+static const char head0[] = "Rank Owner Job Files";
+static const char head1[] = "Total Size\n";
static void alarmer(int);
static void inform(char *, int);
diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c
index e0d708b7b86..689c9b6c1f0 100644
--- a/usr.sbin/pppd/options.c
+++ b/usr.sbin/pppd/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.25 2011/10/02 06:25:53 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.26 2013/10/27 18:49:25 guenther Exp $ */
/*
* options.c - handles option processing for PPP.
@@ -399,7 +399,7 @@ static struct cmd {
#define IMPLEMENTATION ""
#endif
-static char *usage_string = "\
+static const char usage_string[] = "\
pppd version %s patch level %d%s\n\
Usage: %s [ options ], where options are:\n\
<device> Communicate over the named device\n\
diff --git a/usr.sbin/tcpdump/print-bootp.c b/usr.sbin/tcpdump/print-bootp.c
index 7991f0d7d65..f7fdfd73ddc 100644
--- a/usr.sbin/tcpdump/print-bootp.c
+++ b/usr.sbin/tcpdump/print-bootp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print-bootp.c,v 1.17 2009/10/27 23:59:55 deraadt Exp $ */
+/* $OpenBSD: print-bootp.c,v 1.18 2013/10/27 18:49:25 guenther Exp $ */
/*
* Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
@@ -443,7 +443,7 @@ static void
cmu_print(register const u_char *bp, register u_int length)
{
register const struct cmu_vend *cmu;
- char *fmt = " %s:%s";
+ static const char fmt[] = " %s:%s";
#define PRINTCMUADDR(m, s) { TCHECK(cmu->m); \
if (cmu->m.s_addr != 0) \