cURL / Mailing Lists / curl-library / Single Mail

curl-library

Patches for uninitialised data

From: Gisle Vanem <gvanem_at_broadpark.no>
Date: Thu, 15 Jan 2004 19:24:23 +0100

Some functions could by freak accident return an uninitialised value:

content_encoding.c: In function `Curl_unencode_deflate_write':
content_encoding.c:76: warning: `result' might be used uninitialized in this function
content_encoding.c: In function `Curl_unencode_gzip_write':
content_encoding.c:220: warning: `result' might be used uninitialized in this function

and

ssluse.c: In function `verifyhost':
ssluse.c:786: warning: `addrlen' might be used uninitialized in this function
ssluse.c:812: warning: `hostlen' might be used uninitialized in this function
ssluse.c:813: warning: `domainlen' might be used uninitialized in this function
ssluse.c:814: warning: `domain' might be used uninitialized in this function

A fix by initialising to 0 (CURLE_OK) would at last silence "gcc -Wall".
Or should the values be set to CURLE_LAST (or a new CURLE_UNEXP) to
indicate an unusual code-path?

------------
--- CVS-latest/lib/content_encoding.c Wed Jan 07 10:19:35 2004
+++ ./lib/content_encoding.c Thu Jan 15 19:06:00 2004
@@ -73,7 +73,7 @@
                             ssize_t nread)
 {
   int status; /* zlib status */
- int result; /* Curl_client_write status */
+ int result = CURLE_OK; /*?*/ /* Curl_client_write status */
   char decomp[DSIZ]; /* Put the decompressed data here. */
   z_stream *z = &k->z; /* zlib state structure */
 
@@ -217,7 +217,7 @@
                          ssize_t nread)
 {
   int status; /* zlib status */
- int result; /* Curl_client_write status */
+ int result = CURLE_OK; /*?*/ /* Curl_client_write status */
   char decomp[DSIZ]; /* Put the decompressed data here. */
   z_stream *z = &k->z; /* zlib state structure */
 
 --- CVS-latest/lib/ssluse.c Wed Jan 07 10:19:35 2004
+++ ./lib/ssluse.c Thu Jan 15 19:00:17 2004
@@ -783,7 +783,7 @@
   char peer_CN[257];
   bool matched = FALSE; /* no alternative match yet */
   int target = GEN_DNS; /* target type, GEN_DNS or GEN_IPADD */
- int addrlen;
+ int addrlen = 0;
   struct SessionHandle *data = conn->data;
   STACK_OF(GENERAL_NAME) *altnames;
 #ifdef ENABLE_IPV6
@@ -809,9 +809,9 @@
   altnames = X509_get_ext_d2i(server_cert, NID_subject_alt_name, NULL, NULL);
   
   if(altnames) {
- int hostlen;
- int domainlen;
- char *domain;
+ int hostlen = 0;
+ int domainlen = 0;
+ char *domain = NULL;
     int numalts;
     int i;

--- CVS-latest/src/main.c Thu Jan 15 08:09:23 2004
+++ src/main.c Thu Jan 15 19:19:57 2004
@@ -2567,7 +2567,7 @@
 
   int separator = 0;
   
- FILE *infd;
+ FILE *infd = stdin;
   bool infdfopen;
   FILE *headerfilep = NULL;
   char *urlbuffer=NULL;

--- CVS-latest/src/urlglob.c Wed Jan 07 10:19:36 2004
+++ src/urlglob.c Thu Jan 15 19:20:56 2004
@@ -435,8 +435,8 @@
   int allocsize;
   int stringlen=0;
   char numbuf[18];
- char *appendthis;
- int appendlen;
+ char *appendthis = NULL;
+ int appendlen = 0;
 
   /* We cannot use the glob_buffer for storage here since the filename may
    * be longer than the URL we use. We allocate a good start size, then

------------

--gv

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Received on 2004-01-15