bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH] Fixing C89 warnings


From: Darshit Shah
Subject: Re: [Bug-wget] [PATCH] Fixing C89 warnings
Date: Wed, 19 Nov 2014 22:07:28 +0530
User-agent: Mutt/1.5.23 (2014-03-12)

On 11/18, Tim Rühsen wrote:
This patch fixes most C89 warnings for me (-std=c89 -pedantic) since these may
prevent from compiling with MSVC.

There are still some warnings "ISO C forbids conversion of function pointer to
object pointer type [-Wpedantic]" left over. I'll care for these the next
days. There are architectures where function pointers have a different size
from void *. That's why this warning has a meaning.

Tim

From 11baace21e1fa04a92baa395f38ebad8001e9762 Mon Sep 17 00:00:00 2001
From: Tim Ruehsen <address@hidden>
Date: Tue, 18 Nov 2014 22:00:48 +0100
Subject: [PATCH] Trivial fixes for C89 compliancy.

<snip>
diff --git a/src/gnutls.c b/src/gnutls.c
index 87d1d0b..42201e5 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -54,6 +54,10 @@ as that of the covered work.  */
# include "w32sock.h"
#endif

+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#endif
+
#include "host.h"

static int
@@ -122,9 +126,10 @@ ssl_init (void)
          while ((dent = readdir (dir)) != NULL)
            {
              struct stat st;
-              char ca_file[dirlen + strlen(dent->d_name) + 2];
+              size_t ca_file_length = dirlen + strlen(dent->d_name) + 2;
+              char *ca_file = alloca(ca_file_length);

What happens when HAVE_ALLOCA_H is not defined? The above code will attempt to call a function that does not exist and Wget will crash.

I think, we can simply malloc / free() these. Sure alloca is more convenient, but we need a valid fallback for when it is not available.
-              snprintf (ca_file, sizeof(ca_file), "%s/%s", ca_directory, 
dent->d_name);
+              snprintf (ca_file, ca_file_length, "%s/%s", ca_directory, 
dent->d_name);
              if (stat (ca_file, &st) != 0)
                continue;



The rest of the changes look pretty standard and harmless. I'm fine with this patch. Push it once this alloca business has been sorted out.


--
Thanking You,
Darshit Shah

Attachment: pgpiKNp9FBbIB.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]