diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-25 09:11:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-25 09:11:03 +0000 |
commit | c2bdd02a7eec1135cef3ddd6fdc3269a775e544e (patch) | |
tree | ed29df48776d230e00a4e07eeac5fca8955ce494 /lib/libc/regex | |
parent | da8f4ecf268cdf594ae61878f9754ef93b6aa5d7 (diff) |
remaining easy snprintf conversions
Diffstat (limited to 'lib/libc/regex')
-rw-r--r-- | lib/libc/regex/engine.c | 8 | ||||
-rw-r--r-- | lib/libc/regex/regerror.c | 14 |
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index d5f0d2f3e84..c272093217d 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.5 2002/02/16 21:27:24 millert Exp $ */ +/* $OpenBSD: engine.c,v 1.6 2002/05/25 09:11:02 deraadt Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 Henry Spencer. @@ -40,7 +40,7 @@ */ #if defined(SNAMES) && defined(LIBC_SCCS) && !defined(lint) -static char enginercsid[] = "$OpenBSD: engine.c,v 1.5 2002/02/16 21:27:24 millert Exp $"; +static char enginercsid[] = "$OpenBSD: engine.c,v 1.6 2002/05/25 09:11:02 deraadt Exp $"; #endif /* SNAMES and LIBC_SCCS and not lint */ /* @@ -1078,9 +1078,9 @@ int ch; static char pbuf[10]; if (isprint(ch) || ch == ' ') - (void)sprintf(pbuf, "%c", ch); + (void)snprintf(pbuf, sizeof pbuf, "%c", ch); else - (void)sprintf(pbuf, "\\%o", ch); + (void)snprintf(pbuf, sizeof pbuf, "\\%o", ch); return(pbuf); } #endif diff --git a/lib/libc/regex/regerror.c b/lib/libc/regex/regerror.c index 976a7d6bc4e..8664772a27d 100644 --- a/lib/libc/regex/regerror.c +++ b/lib/libc/regex/regerror.c @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; #else -static char rcsid[] = "$OpenBSD: regerror.c,v 1.8 2002/05/24 21:22:37 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: regerror.c,v 1.9 2002/05/25 09:11:02 deraadt Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -61,7 +61,7 @@ extern "C" { #endif /* === regerror.c === */ -static char *regatoi(const regex_t *preg, char *localbuf); +static char *regatoi(const regex_t *preg, char *localbuf, int localbufsize); #ifdef __cplusplus } @@ -130,7 +130,7 @@ size_t errbuf_size; char convbuf[50]; if (errcode == REG_ATOI) - s = regatoi(preg, convbuf); + s = regatoi(preg, convbuf, sizeof convbuf); else { for (r = rerrs; r->code != 0; r++) if (r->code == target) @@ -141,7 +141,8 @@ size_t errbuf_size; assert(strlen(r->name) < sizeof(convbuf)); (void) strlcpy(convbuf, r->name, sizeof convbuf); } else - (void)sprintf(convbuf, "REG_0x%x", target); + (void)snprintf(convbuf, sizeof convbuf, + "REG_0x%x", target); s = convbuf; } else s = r->explain; @@ -160,9 +161,10 @@ size_t errbuf_size; == static char *regatoi(const regex_t *preg, char *localbuf); */ static char * -regatoi(preg, localbuf) +regatoi(preg, localbuf, localbufsize) const regex_t *preg; char *localbuf; +int localbufsize; { register struct rerr *r; @@ -172,6 +174,6 @@ char *localbuf; if (r->code == 0) return("0"); - (void)sprintf(localbuf, "%d", r->code); + (void)snprintf(localbuf, localbufsize, "%d", r->code); return(localbuf); } |