From a623d7c672cb99301a9e7f294ee836f9795f5af5 Mon Sep 17 00:00:00 2001 From: dholland Date: Tue, 26 May 2009 00:00:56 +0000 Subject: sprintf -> snprintf --- atc/input.c | 7 ++++--- atc/log.c | 13 +++++++------ atc/update.c | 24 +++++++++++++++--------- 3 files changed, 26 insertions(+), 18 deletions(-) (limited to 'atc') diff --git a/atc/input.c b/atc/input.c index 215c3c30..a2b49f5a 100644 --- a/atc/input.c +++ b/atc/input.c @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.22 2007/12/15 19:44:38 perry Exp $ */ +/* $NetBSD: input.c,v 1.23 2009/05/26 00:00:56 dholland Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: input.c,v 1.22 2007/12/15 19:44:38 perry Exp $"); +__RCSID("$NetBSD: input.c,v 1.23 2009/05/26 00:00:56 dholland Exp $"); #endif #endif /* not lint */ @@ -208,7 +208,8 @@ push(int ruleno, int ch) int newstate, newpos; assert(level < (MAXDEPTH - 1)); - (void)sprintf(T_STR, st[T_STATE].rule[ruleno].str, tval); + (void)snprintf(T_STR, sizeof(T_STR), + st[T_STATE].rule[ruleno].str, tval); T_RULE = ruleno; T_CH = ch; newstate = st[T_STATE].rule[ruleno].to_state; diff --git a/atc/log.c b/atc/log.c index b333ce5f..3f9572a0 100644 --- a/atc/log.c +++ b/atc/log.c @@ -1,4 +1,4 @@ -/* $NetBSD: log.c,v 1.19 2007/12/15 19:44:38 perry Exp $ */ +/* $NetBSD: log.c,v 1.20 2009/05/26 00:00:56 dholland Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: log.c,v 1.19 2007/12/15 19:44:38 perry Exp $"); +__RCSID("$NetBSD: log.c,v 1.20 2009/05/26 00:00:56 dholland Exp $"); #endif #endif /* not lint */ @@ -84,13 +84,14 @@ timestr(int t) static char s[80]; if (DAY(t) > 0) - (void)sprintf(s, "%dd+%02dhrs", DAY(t), HOUR(t)); + (void)snprintf(s, sizeof(s), "%dd+%02dhrs", DAY(t), HOUR(t)); else if (HOUR(t) > 0) - (void)sprintf(s, "%d:%02d:%02d", HOUR(t), MIN(t), SEC(t)); + (void)snprintf(s, sizeof(s), "%d:%02d:%02d", HOUR(t), MIN(t), + SEC(t)); else if (MIN(t) > 0) - (void)sprintf(s, "%d:%02d", MIN(t), SEC(t)); + (void)snprintf(s, sizeof(s), "%d:%02d", MIN(t), SEC(t)); else if (SEC(t) > 0) - (void)sprintf(s, ":%02d", SEC(t)); + (void)snprintf(s, sizeof(s), ":%02d", SEC(t)); else *s = '\0'; diff --git a/atc/update.c b/atc/update.c index 90969937..0fcc967f 100644 --- a/atc/update.c +++ b/atc/update.c @@ -1,4 +1,4 @@ -/* $NetBSD: update.c,v 1.19 2007/12/15 19:44:38 perry Exp $ */ +/* $NetBSD: update.c,v 1.20 2009/05/26 00:00:56 dholland Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,7 +46,7 @@ #if 0 static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: update.c,v 1.19 2007/12/15 19:44:38 perry Exp $"); +__RCSID("$NetBSD: update.c,v 1.20 2009/05/26 00:00:56 dholland Exp $"); #endif #endif /* not lint */ @@ -201,7 +201,8 @@ update(int dummy __unused) if (too_close(p1, p2, 1)) { static char buf[80]; - (void)sprintf(buf, "collided with plane '%c'.", + (void)snprintf(buf, sizeof(buf), + "collided with plane '%c'.", name(p2)); loser(p1, buf); } @@ -222,29 +223,34 @@ const char * command(const PLANE *pp) { static char buf[50], *bp, *comm_start; + size_t bpsize; buf[0] = '\0'; bp = buf; - (void)sprintf(bp, "%c%d%c%c%d: ", name(pp), pp->altitude, + bpsize = sizeof(buf); + (void)snprintf(bp, bpsize, "%c%d%c%c%d: ", name(pp), pp->altitude, (pp->fuel < LOWFUEL) ? '*' : ' ', (pp->dest_type == T_AIRPORT) ? 'A' : 'E', pp->dest_no); comm_start = bp = strchr(buf, '\0'); + bpsize = buf + sizeof(buf) - bp; if (pp->altitude == 0) - (void)sprintf(bp, "Holding @ A%d", pp->orig_no); + (void)snprintf(bp, bpsize, "Holding @ A%d", pp->orig_no); else if (pp->new_dir >= MAXDIR || pp->new_dir < 0) - (void)strcpy(bp, "Circle"); + (void)snprintf(bp, bpsize, "Circle"); else if (pp->new_dir != pp->dir) - (void)sprintf(bp, "%d", dir_deg(pp->new_dir)); + (void)snprintf(bp, bpsize, "%d", dir_deg(pp->new_dir)); bp = strchr(buf, '\0'); + bpsize = buf + sizeof(buf) - bp; if (pp->delayd) - (void)sprintf(bp, " @ B%d", pp->delayd_no); + (void)snprintf(bp, bpsize, " @ B%d", pp->delayd_no); bp = strchr(buf, '\0'); + bpsize = buf + sizeof(buf) - bp; if (*comm_start == '\0' && (pp->status == S_UNMARKED || pp->status == S_IGNORED)) - (void)strcpy(bp, "---------"); + (void)snprintf(bp, bpsize, "---------"); return (buf); } -- cgit v1.2.3-56-ge451