Wireshark-dev: Re: [Wireshark-dev] Warings/error in packet-ssl.c
From: Paolo Abeni <[email protected]>
Date: Mon, 23 Apr 2007 09:29:39 +0200
Hello,

On Sun, 2007-04-22 at 23:06 +0200, Joerg Mayer wrote:
> Can someone please have a look at uand fix the following warning:
> 
> cc1: warnings being treated as errors
> packet-ssl.c: In function 'ssl_parse':
> packet-ssl.c:334: warning: ignoring return value of 'fread', declared
> with attribute warn_unused_result

The attached patch fix the issue. It also try to fix a bit the
indentation.

ciao,

Paolo

 
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Problemi di Liquidità? Con Logos Finanziaria 30.000 € in 24 ore a dipendenti e lavoratori autonomi con rimborsi fino a 120 mesi clicca qui
* 
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=2907&d=23-4
Index: epan/dissectors/packet-ssl.c
===================================================================
--- epan/dissectors/packet-ssl.c	(revision 21522)
+++ epan/dissectors/packet-ssl.c	(working copy)
@@ -302,9 +302,9 @@
     ep_stack_t tmp_stack;
     SslAssociation *tmp_assoc;
     FILE *ssl_keys_file;
-	struct stat statb;
-	size_t size;
-	gchar *tmp_buf;
+    struct stat statb;
+    size_t size;
+    gchar *tmp_buf;
 
     ssl_set_debug(ssl_debug_file_name);
 
@@ -326,22 +326,27 @@
 
     if (ssl_keys_list && (ssl_keys_list[0] != 0))
     {
-		if (file_exists(ssl_keys_list)) {
-		    if ((ssl_keys_file = fopen(ssl_keys_list, "r"))) {
-				fstat(fileno(ssl_keys_file), &statb);
-				size = statb.st_size;
-				tmp_buf = ep_alloc0(size + 1);
-				fread(tmp_buf, size, 1, ssl_keys_file);
-				tmp_buf[size] = '\0';
-				fclose(ssl_keys_file);
-		        ssl_parse_key_list(tmp_buf,ssl_key_hash,ssl_associations,ssl_handle,TRUE);
-			} else {
-        		report_open_failure(ssl_keys_list, errno, FALSE);
-		    }
-
-		} else {
-	        ssl_parse_key_list(ssl_keys_list,ssl_key_hash,ssl_associations,ssl_handle,TRUE);
-		}
+        if (file_exists(ssl_keys_list)) {
+            if ((ssl_keys_file = fopen(ssl_keys_list, "r"))) {
+                size_t nbytes;
+                fstat(fileno(ssl_keys_file), &statb);
+                size = statb.st_size;
+                tmp_buf = ep_alloc0(size + 1);
+                nbytes = fread(tmp_buf, size, 1, ssl_keys_file);
+                fclose(ssl_keys_file);
+                if (nbytes != size)
+                    report_failure("can't read whole data from %s expeted %d bytes, read %d",
+                                  ssl_keys_list, size, nbytes);
+                else {
+                    tmp_buf[size] = '\0';
+                    ssl_parse_key_list(tmp_buf,ssl_key_hash,ssl_associations,ssl_handle,TRUE);
+                }
+            } else {
+                report_open_failure(ssl_keys_list, errno, FALSE);
+            }
+        } else {
+            ssl_parse_key_list(ssl_keys_list,ssl_key_hash,ssl_associations,ssl_handle,TRUE);
+        }
     }
 
 }