summaryrefslogtreecommitdiff
path: root/lib/libc/regex/regerror.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-25 09:11:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-25 09:11:03 +0000
commitc2bdd02a7eec1135cef3ddd6fdc3269a775e544e (patch)
treeed29df48776d230e00a4e07eeac5fca8955ce494 /lib/libc/regex/regerror.c
parentda8f4ecf268cdf594ae61878f9754ef93b6aa5d7 (diff)
remaining easy snprintf conversions
Diffstat (limited to 'lib/libc/regex/regerror.c')
-rw-r--r--lib/libc/regex/regerror.c14
1 files changed, 8 insertions, 6 deletions
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);
}