]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Cleanup a couple of sprintf calls in regex library.
authorRobert Colquhoun <rjc@trump.net.au>
Wed, 20 Sep 2000 05:10:20 +0000 (05:10 +0000)
committerRobert Colquhoun <rjc@trump.net.au>
Wed, 20 Sep 2000 05:10:20 +0000 (05:10 +0000)
regex/.cvsignore
regex/engine.c
regex/regerror.c

index a0c387ef18302b3ad871e95e8de4f074b725dda1..3b134ff98d5ae9535c1d454ccf06a2a809e69ec8 100644 (file)
@@ -1,2 +1,3 @@
 .cdependtime
+Makedepend
 Makefile
index 76914f25dce2a5c6a7f26590e9e5673a1fee4601..85881824be978e5d8654018f12716d8447aa5184 100644 (file)
@@ -1065,9 +1065,9 @@ int ch;
        static char pbuf[10];
 
        if (isprint(ch) || ch == ' ')
-               sprintf(pbuf, "%c", ch);
+               snprintf(pbuf, sizeof(pbuf), "%c", ch);
        else
-               sprintf(pbuf, "\\%o", ch);
+               snprintf(pbuf, sizeof(pbuf), "\\%o", ch);
        return(pbuf);
 }
 #endif
index b03b08ffd1d3200edbed73b63579c7a19948c8d2..b7fb3bf193b584c524acc71d1ffe0ad3a16109ce 100644 (file)
@@ -57,7 +57,7 @@ extern "C" {
 #endif
 
 /* === regerror.c === */
-static char *regatoi(const regex_t *preg, char *localbuf);
+static char *regatoi(const regex_t *preg, char *localbuf, size_t buflen);
 
 #ifdef __cplusplus
 }
@@ -126,7 +126,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)
@@ -136,7 +136,7 @@ size_t errbuf_size;
                        if (r->code != 0)
                                (void) strcpy(convbuf, r->name);
                        else
-                               sprintf(convbuf, "REG_0x%x", target);
+                               snprintf(convbuf, sizeof(convbuf), "REG_0x%x", target);
                        assert(strlen(convbuf) < sizeof(convbuf));
                        s = convbuf;
                } else
@@ -158,12 +158,13 @@ size_t errbuf_size;
 
 /*
  - regatoi - internal routine to implement REG_ATOI
- == static char *regatoi(const regex_t *preg, char *localbuf);
+ == static char *regatoi(const regex_t *preg, char *localbuf, size_t buflen);
  */
 static char *
-regatoi(preg, localbuf)
+regatoi(preg, localbuf, buflen)
 const regex_t *preg;
 char *localbuf;
+size_t buflen;
 {
        register struct rerr *r;
 
@@ -173,6 +174,6 @@ char *localbuf;
        if (r->code == 0)
                return("0");
 
-       sprintf(localbuf, "%d", r->code);
+       snprintf(localbuf, buflen, "%d", r->code);
        return(localbuf);
 }