Am Mittwoch, 19. November 2014, 22:07:28 schrieb Darshit Shah:
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.
There are systems without alloca.h header file. Thus the check.
(I just had an error report for libpsl with this issue.)