]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix #831: workaround for spurious fread_chk warning against petal.c
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 9 Sep 2016 05:55:16 +0000 (05:55 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 9 Sep 2016 05:55:16 +0000 (05:55 +0000)
git-svn-id: file:///svn/unbound/trunk@3851 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
testcode/petal.c

index 92b9e0c817258f9ad41f8430d1988990d4c12c35..818b4a8a866a5bdb2897c9bbb7d9da7d9324b6da 100644 (file)
@@ -1,3 +1,6 @@
+9 September 2016: Wouter
+       - Fix #831: workaround for spurious fread_chk warning against petal.c
+
 5 September 2016: Ralph
        - Take configured minimum TTL into consideration when reducing TTL
          to original TTL from RRSIG.
index def0f5e25d3f228b29b97709698f64a7088fd2b8..be8f3bde00f45072f009764d9d450d2510f56377 100644 (file)
@@ -429,6 +429,7 @@ static void
 provide_file_chunked(SSL* ssl, char* fname)
 {
        char buf[16384];
+       char* tmpbuf = NULL;
        char* at = buf;
        size_t avail = sizeof(buf);
        size_t r;
@@ -471,9 +472,13 @@ provide_file_chunked(SSL* ssl, char* fname)
        }
 
        do {
-               char tmpbuf[sizeof(buf)];
+               size_t red;
+               free(tmpbuf);
+               tmpbuf = malloc(avail-16);
+               if(!tmpbuf)
+                       break;
                /* read chunk; space-16 for xxxxCRLF..CRLF0CRLFCRLF (3 spare)*/
-               size_t red = in?fread(tmpbuf, 1, avail-16, in):0;
+               red = in?fread(tmpbuf, 1, avail-16, in):0;
                /* prepare chunk */
                snprintf(at, avail, "%x\r\n", (unsigned)red);
                r = strlen(at);
@@ -514,6 +519,7 @@ provide_file_chunked(SSL* ssl, char* fname)
                avail = sizeof(buf);
        } while(in && !feof(in) && !ferror(in));
 
+       free(tmpbuf);
        if(in) fclose(in);
 }