]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix snprintf return value usage, fixed libunbound_get_option.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 19 Apr 2013 11:34:36 +0000 (11:34 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 19 Apr 2013 11:34:36 +0000 (11:34 +0000)
git-svn-id: file:///svn/unbound/trunk@2888 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/petal.c
util/config_file.c

index 512c42497748ae642b560a530b38f9cd36d15b78..ed12bf5667995a431bf0e7e33360f127aff7c97b 100644 (file)
@@ -1,3 +1,6 @@
+19 April 2013: Wouter
+       - Fixup snprintf return value usage, fixed libunbound_get_option.
+
 18 April 2013: Wouter
        - fix bug #491: pick program name (0th argument) as syslog identity.
        - own implementation of compat/snprintf.c.
index 14a187e3ff2633661b9bcb104247457e21e7e104..435d0b239b73d99cb282b12627ad73854ca69e58 100644 (file)
@@ -354,7 +354,8 @@ provide_file_10(SSL* ssl, char* fname)
        if(!in) {
                char hdr[1024];
                rcode = "404 File not found";
-               r = snprintf(hdr, sizeof(hdr), "HTTP/1.1 %s\r\n\r\n", rcode);
+               snprintf(hdr, sizeof(hdr), "HTTP/1.1 %s\r\n\r\n", rcode);
+               r = strlen(hdr);
                if(SSL_write(ssl, hdr, r) <= 0) {
                        /* write failure */
                }
@@ -371,16 +372,20 @@ provide_file_10(SSL* ssl, char* fname)
        }
        avail = len+header_reserve;
        at = buf;
-       r = snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode);
+       snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode);
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION);
+       snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION);
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "Content-Length: %u\r\n", (unsigned)len);
+       snprintf(at, avail, "Content-Length: %u\r\n", (unsigned)len);
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "\r\n");
+       snprintf(at, avail, "\r\n");
+       r = strlen(at);
        at += r;
        avail -= r;
        if(avail < len) { /* robust */
@@ -423,19 +428,24 @@ provide_file_chunked(SSL* ssl, char* fname)
        }
 
        /* print headers */
-       r = snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode);
+       snprintf(at, avail, "HTTP/1.1 %s\r\n", rcode);
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION);
+       snprintf(at, avail, "Server: petal/%s\r\n", PACKAGE_VERSION);
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "Transfer-Encoding: chunked\r\n");
+       snprintf(at, avail, "Transfer-Encoding: chunked\r\n");
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "Connection: close\r\n");
+       snprintf(at, avail, "Connection: close\r\n");
+       r = strlen(at);
        at += r;
        avail -= r;
-       r = snprintf(at, avail, "\r\n");
+       snprintf(at, avail, "\r\n");
+       r = strlen(at);
        at += r;
        avail -= r;
        if(avail < 16) { /* robust */
@@ -448,7 +458,8 @@ provide_file_chunked(SSL* ssl, char* fname)
                /* read chunk; space-16 for xxxxCRLF..CRLF0CRLFCRLF (3 spare)*/
                size_t red = in?fread(tmpbuf, 1, avail-16, in):0;
                /* prepare chunk */
-               r = snprintf(at, avail, "%x\r\n", (unsigned)red);
+               snprintf(at, avail, "%x\r\n", (unsigned)red);
+               r = strlen(at);
                if(verb >= 3)
                {printf("chunk len %x\n", (unsigned)red); fflush(stdout);}
                at += r;
@@ -458,17 +469,20 @@ provide_file_chunked(SSL* ssl, char* fname)
                        memmove(at, tmpbuf, red);
                        at += red;
                        avail -= red;
-                       r = snprintf(at, avail, "\r\n");
+                       snprintf(at, avail, "\r\n");
+                       r = strlen(at);
                        at += r;
                        avail -= r;
                }
                if(in && feof(in) && red != 0) {
-                       r = snprintf(at, avail, "0\r\n");
+                       snprintf(at, avail, "0\r\n");
+                       r = strlen(at);
                        at += r;
                        avail -= r;
                }
                if(!in || feof(in)) {
-                       r = snprintf(at, avail, "\r\n");
+                       snprintf(at, avail, "\r\n");
+                       r = strlen(at);
                        at += r;
                        avail -= r;
                }
index b946f0df0dc563c586996f250b9d29651d799999..32c86a84179aa8e71885f2bc6f6483f03030308b 100644 (file)
@@ -516,8 +516,9 @@ config_collate_cat(struct config_strlist* list)
                        return NULL;
                }
                snprintf(w, left, "%s\n", s->str);
-               w += this+1;
-               left -= this+1;
+               this = strlen(w);
+               w += this;
+               left -= this;
        }
        return r;
 }