0
0
Fork 0
haikuports/net-misc/wget/patches/wget-1.21.1.patchset

1190 lines
32 KiB
Plaintext

From c971e042ef3eff56becf4f32a747dacc951ba55c Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 19 May 2014 15:38:37 +0000
Subject: apply wget-1.14.patch
diff --git a/configure.ac b/configure.ac
index d47e4bb..6d719e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,6 +311,7 @@ AC_HEADER_STDBOOL
AC_CHECK_HEADERS(unistd.h sys/time.h)
AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h)
AC_CHECK_HEADERS(stdint.h inttypes.h pwd.h wchar.h dlfcn.h)
+AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_DECLS(h_errno,,,[#include <netdb.h>])
@@ -485,6 +486,9 @@ dnl
PKG_PROG_PKG_CONFIG
+AC_CHECK_LIB(network, gethostbyname)
+AC_CHECK_LIB(network, socket)
+
AS_IF([test "x$with_libpsl" != xno], [
PKG_CHECK_MODULES([LIBPSL], libpsl, [
with_libpsl=yes
diff --git a/src/config.h.in b/src/config.h.in
index ee00138..2835c93 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -1130,6 +1130,9 @@
/* Define if libcares is available. */
#undef HAVE_LIBCARES
+/* Define to 1 if you have the `bind' library (-lbind). */
+#undef HAVE_LIBBIND
+
/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL
@@ -1142,6 +1145,9 @@
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
+/* Define to 1 if you have the `network' library (-lnetwork). */
+#undef HAVE_LIBNETWORK
+
/* Define if libpcre is available. */
#undef HAVE_LIBPCRE
diff --git a/src/connect.c b/src/connect.c
index 16d0102..3d62c85 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -46,7 +46,7 @@ as that of the covered work. */
# include <netdb.h>
# endif /* def __VMS [else] */
# include <netinet/in.h>
-# ifndef __BEOS__
+# ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
# endif
#endif /* not WINDOWS */
diff --git a/src/host.h b/src/host.h
index b1e1f68..7eff616 100644
--- a/src/host.h
+++ b/src/host.h
@@ -41,9 +41,9 @@ as that of the covered work. */
# endif /* def __VMS [else] */
# include <sys/socket.h>
# include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#endif
+# ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+# endif
#endif
struct url;
--
2.30.0
From e1e94752f3cee586e296fa432354ea04352e4e35 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 19 May 2014 15:47:24 +0000
Subject: apply and augment wget-1.14-build-fixes.patch
diff --git a/src/utils.c b/src/utils.c
index 4115ec5..ebd89a5 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -60,7 +60,9 @@ as that of the covered work. */
/* For TIOCGWINSZ and friends: */
#ifndef WINDOWS
+#ifndef __HAIKU__
# include <sys/ioctl.h>
+#endif
# include <termios.h>
#endif
--
2.30.0
From e038e5864071bd3bc71ebac7baa2266189cab577 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 14 Feb 2016 11:05:10 +0100
Subject: Move wget-hsts out of home directory.
diff --git a/src/main.c b/src/main.c
index e506b21..48b84fa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -87,6 +87,10 @@ as that of the covered work. */
# include "vms.h"
#endif /* __VMS */
+#ifdef __HAIKU__
+#include "FindDirectory.h"
+#endif
+
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
#endif
@@ -176,6 +180,16 @@ get_hsts_database (void)
if (opt.hsts_file)
return xstrdup (opt.hsts_file);
+#ifdef __HAIKU__
+ {
+ char buffer[256];
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, buffer, sizeof(buffer)) == B_OK) {
+ char *dir = aprintf("%s/wget-hsts", buffer);
+ return dir;
+ }
+ }
+#endif
+
if (opt.homedir)
{
char *dir = ajoin_dir_file(opt.homedir, ".wget-hsts");
--
2.30.0
From f04146268e15b8b340233e175e7c8762ab17e4cc Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 22 May 2017 18:46:27 +0200
Subject: gcc2 patch
diff --git a/src/init.c b/src/init.c
index a94f19f..effa11d 100644
--- a/src/init.c
+++ b/src/init.c
@@ -922,7 +922,7 @@ setval_internal (int comind, const char *com, const char *val)
assert (0 <= comind && ((size_t) comind) < countof (commands));
if ((unsigned) comind >= countof (commands))
- return NULL;
+ return false;
DEBUGP (("Setting %s (%s) to %s\n", com, commands[comind].name, val));
return commands[comind].action (com, val, commands[comind].place);
--
2.30.0
From 6e71f97fed7ec56241257a042a2e96bc28a2c39e Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Thu, 23 Nov 2017 09:09:48 +0100
Subject: Handle SSL_ERROR_WANT_READ.
According to OpenSSL docs this isn't supposed to happen, but it does
and I can't figure out where it would be intercepted in OpenSSL side.
So let's just handle it and retry reads when requestred to do so.
This allows EINTR detection to work, so no error happens when you
resize terminal anymore.
diff --git a/src/openssl.c b/src/openssl.c
index 9d86bc8..33f4273 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -497,7 +497,8 @@ openssl_read_peek_callback(void *arg)
{
ret = fn (conn, buf, bufsize);
}
- while (ret == -1 && SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL && errno == EINTR);
+ while (ret == -1 && (SSL_get_error (conn, ret) == SSL_ERROR_SYSCALL
+ || SSL_get_error (conn, ret) == SSL_ERROR_WANT_READ) && errno == EINTR);
args->retval = ret;
}
--
2.30.0
From 8d467891c25c5f0dbc0cf0eb9735ed4d66b141bb Mon Sep 17 00:00:00 2001
From: Crestwave <crest.wave@yahoo.com>
Date: Sun, 25 Nov 2018 12:01:08 +0000
Subject: Also move wget-hsts-test out of the home directory in hsts.c.
diff --git a/src/hsts.c b/src/hsts.c
index ead5b72..9e5f3d1 100644
--- a/src/hsts.c
+++ b/src/hsts.c
@@ -49,6 +49,10 @@ as that of the covered work. */
#include <stdio.h>
#include <sys/file.h>
+#ifdef __HAIKU__
+#include "FindDirectory.h"
+#endif
+
struct hsts_store {
struct hash_table *table;
time_t last_mtime;
@@ -628,9 +632,22 @@ get_hsts_store_filename (void)
char *filename = NULL;
FILE *fp = NULL;
+#ifdef __HAIKU__
+ {
+ char buffer[256];
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, buffer, sizeof(buffer)) == B_OK) {
+ filename = ajoin_dir_file (buffer, ".wget-hsts-test");
+ }
+ }
+#endif
+
if (opt.homedir)
{
filename = ajoin_dir_file (opt.homedir, ".wget-hsts-test");
+ }
+
+ if (filename)
+ {
fp = fopen (filename, "w");
if (fp)
fclose (fp);
--
2.30.0
From 272c92c21b66aef8c9cc4919553eac5e7f11e44e Mon Sep 17 00:00:00 2001
From: Crestwave <crest.wave@yahoo.com>
Date: Mon, 26 Nov 2018 07:13:07 +0000
Subject: Fix segmentation violation when executing fuzzers.
diff --git a/fuzz/wget_cookie_fuzzer.c b/fuzz/wget_cookie_fuzzer.c
index a6e7e8e..f1bd8ed 100644
--- a/fuzz/wget_cookie_fuzzer.c
+++ b/fuzz/wget_cookie_fuzzer.c
@@ -58,11 +58,13 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
return NULL;
}
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_css_fuzzer.c b/fuzz/wget_css_fuzzer.c
index 7553f8a..2bed52e 100644
--- a/fuzz/wget_css_fuzzer.c
+++ b/fuzz/wget_css_fuzzer.c
@@ -69,6 +69,7 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
static int do_jump;
static jmp_buf jmpbuf;
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
@@ -89,6 +90,7 @@ void exit(int status)
}
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_ftpls_fuzzer.c b/fuzz/wget_ftpls_fuzzer.c
index 15ed1e9..30b897e 100644
--- a/fuzz/wget_ftpls_fuzzer.c
+++ b/fuzz/wget_ftpls_fuzzer.c
@@ -61,6 +61,7 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
static int do_jump;
static jmp_buf jmpbuf;
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
@@ -81,6 +82,7 @@ void exit(int status)
}
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_html_fuzzer.c b/fuzz/wget_html_fuzzer.c
index cf949eb..f3094ec 100644
--- a/fuzz/wget_html_fuzzer.c
+++ b/fuzz/wget_html_fuzzer.c
@@ -68,11 +68,13 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
#endif
}
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_netrc_fuzzer.c b/fuzz/wget_netrc_fuzzer.c
index 0b1386f..8d89a20 100644
--- a/fuzz/wget_netrc_fuzzer.c
+++ b/fuzz/wget_netrc_fuzzer.c
@@ -60,6 +60,7 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
static int do_jump;
static jmp_buf jmpbuf;
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
@@ -80,6 +81,7 @@ void exit(int status)
}
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_options_fuzzer.c b/fuzz/wget_options_fuzzer.c
index 107a479..810a088 100644
--- a/fuzz/wget_options_fuzzer.c
+++ b/fuzz/wget_options_fuzzer.c
@@ -62,6 +62,7 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
static int do_jump;
static jmp_buf jmpbuf;
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
@@ -82,6 +83,7 @@ void exit(int status)
}
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_robots_fuzzer.c b/fuzz/wget_robots_fuzzer.c
index 41b41d8..90f385b 100644
--- a/fuzz/wget_robots_fuzzer.c
+++ b/fuzz/wget_robots_fuzzer.c
@@ -59,11 +59,13 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
return NULL;
}
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
diff --git a/fuzz/wget_url_fuzzer.c b/fuzz/wget_url_fuzzer.c
index 51c22eb..fa988f9 100644
--- a/fuzz/wget_url_fuzzer.c
+++ b/fuzz/wget_url_fuzzer.c
@@ -58,11 +58,13 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
return NULL;
}
+#ifndef __HAIKU__
#ifdef FUZZING
void exit_wget(int status)
{
}
#endif
+#endif
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
--
2.30.0
From a34fec0513caf586d1a1ed1c3af91aa8ad1750f6 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 30 Mar 2019 14:19:17 +0100
Subject: gcc2 patch for version 1.21.1
diff --git a/lib/canonicalize.c b/lib/canonicalize.c
index 3a1c809..7540ac5 100644
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -212,10 +212,12 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
return NULL;
}
+{
struct scratch_buffer extra_buffer, link_buffer;
scratch_buffer_init (&extra_buffer);
scratch_buffer_init (&link_buffer);
scratch_buffer_init (rname_buf);
+{
char *rname_on_stack = rname_buf->data;
char *rname = rname_on_stack;
bool end_in_extra_buffer = false;
@@ -299,6 +301,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
/* Length of this file name component; it can be zero if a file
name ends in '/'. */
+{
idx_t startlen = end - start;
if (startlen == 0)
@@ -334,6 +337,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
dest = mempcpy (dest, start, startlen);
*dest = '\0';
+{
char *buf;
ssize_t n = -1;
if (!logical)
@@ -341,11 +345,13 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
while (true)
{
buf = link_buffer.data;
+{
idx_t bufsize = link_buffer.length;
n = readlink (rname, buf, bufsize - 1);
if (n < bufsize - 1)
break;
- if (!scratch_buffer_grow (&link_buffer))
+}
+ if (!scratch_buffer_grow (&link_buffer))
xalloc_die ();
}
}
@@ -384,10 +390,12 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
buf[n] = '\0';
+{
char *extra_buf = extra_buffer.data;
idx_t end_idx IF_LINT (= 0);
if (end_in_extra_buffer)
end_idx = end - extra_buf;
+{
size_t len = strlen (end);
if (INT_ADD_OVERFLOW (len, n))
xalloc_die ();
@@ -431,6 +439,8 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
&& ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
dest++;
}
+}
+}
}
else if (! (can_exist == CAN_MISSING
|| (suffix_requires_dir_check (end)
@@ -443,6 +453,8 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
&& !end[strspn (end, SLASHES)])))
goto error;
}
+ }
+}
}
if (dest > rname + prefix_len + 1 && ISSLASH (dest[-1]))
--dest;
@@ -464,11 +476,15 @@ error:
}
*dest++ = '\0';
+{
char *result = scratch_buffer_dupfree (rname_buf, dest - rname);
if (!result)
xalloc_die ();
return result;
}
+}
+}
+}
/* Return the canonical absolute name of file NAME, while treating
missing elements according to CAN_MODE. A canonical name
diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c
index 15aa522..6473f2c 100644
--- a/lib/fatal-signal.c
+++ b/lib/fatal-signal.c
@@ -218,6 +218,7 @@ at_fatal_signal (action_t action)
if (mt) gl_lock_lock (at_fatal_signal_lock);
+{
static bool cleanup_initialized = false;
if (!cleanup_initialized)
{
@@ -265,6 +266,7 @@ at_fatal_signal (action_t action)
if (mt) gl_lock_unlock (at_fatal_signal_lock);
}
+}
/* ========================================================================= */
diff --git a/lib/filenamecat-lgpl.c b/lib/filenamecat-lgpl.c
index 008a640..c01e2bb 100644
--- a/lib/filenamecat-lgpl.c
+++ b/lib/filenamecat-lgpl.c
@@ -68,6 +68,7 @@ mfile_name_concat (char const *dir, char const *base, char **base_in_result)
sep = '.';
}
+{
char *p_concat = malloc (dirlen + (sep != '\0') + baselen + 1);
if (p_concat == NULL)
return NULL;
@@ -88,3 +89,4 @@ mfile_name_concat (char const *dir, char const *base, char **base_in_result)
return p_concat;
}
+}
diff --git a/lib/findprog-in.c b/lib/findprog-in.c
index 7e0fb4e..5894b33 100644
--- a/lib/findprog-in.c
+++ b/lib/findprog-in.c
@@ -224,6 +224,7 @@ find_in_given_path (const char *progname, const char *path,
if (path_copy == NULL)
return NULL; /* errno is set here */
+{
int failure_errno;
char *path_rest;
char *cp;
@@ -397,3 +398,4 @@ find_in_given_path (const char *progname, const char *path,
return NULL;
}
}
+}
diff --git a/lib/fnmatch.c b/lib/fnmatch.c
index 2db2a3b..f6e99e9 100644
--- a/lib/fnmatch.c
+++ b/lib/fnmatch.c
@@ -338,6 +338,7 @@ fnmatch (const char *pattern, const char *string, int flags)
(void) mbsrtowcs (wstring, &string, n + 1, &ps);
}
+{
int res = internal_fnwmatch (wpattern, wstring, wstring + n,
flags & FNM_PERIOD, flags, NULL,
alloca_used);
@@ -346,6 +347,7 @@ fnmatch (const char *pattern, const char *string, int flags)
free (wpattern_malloc);
return res;
+}
}
return internal_fnmatch (pattern, string, string + strlen (string),
diff --git a/lib/fnmatch_loop.c b/lib/fnmatch_loop.c
index f3e5723..3bc7603 100644
--- a/lib/fnmatch_loop.c
+++ b/lib/fnmatch_loop.c
@@ -1046,6 +1046,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
goto out; \
} \
slen += plensize; \
+{ \
bool malloced = ! __libc_use_alloca (new_used); \
if (__glibc_unlikely (malloced)) \
{ \
@@ -1063,7 +1064,9 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
newp->malloced = malloced; \
*((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0'); \
*lastp = newp; \
- lastp = &newp->next
+ lastp = &newp->next; \
+}
+
NEW_PATTERN;
}
}
diff --git a/lib/malloc/dynarray_emplace_enlarge.c b/lib/malloc/dynarray_emplace_enlarge.c
index 7ac4b6d..01b4085 100644
--- a/lib/malloc/dynarray_emplace_enlarge.c
+++ b/lib/malloc/dynarray_emplace_enlarge.c
@@ -51,9 +51,11 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list,
}
}
+{
size_t new_size;
if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size))
return false;
+ {
void *new_array;
if (list->array == scratch)
{
@@ -70,4 +72,6 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list,
list->allocated = new_allocated;
return true;
}
+}
+}
libc_hidden_def (__libc_dynarray_emplace_enlarge)
diff --git a/lib/malloc/dynarray_finalize.c b/lib/malloc/dynarray_finalize.c
index be9441e..982bf95 100644
--- a/lib/malloc/dynarray_finalize.c
+++ b/lib/malloc/dynarray_finalize.c
@@ -29,6 +29,7 @@ __libc_dynarray_finalize (struct dynarray_header *list,
/* The caller will reported the deferred error. */
return false;
+{
size_t used = list->used;
/* Empty list. */
@@ -42,6 +43,7 @@ __libc_dynarray_finalize (struct dynarray_header *list,
return true;
}
+{
size_t allocation_size = used * element_size;
void *heap_array = malloc (allocation_size);
if (heap_array != NULL)
@@ -59,4 +61,6 @@ __libc_dynarray_finalize (struct dynarray_header *list,
/* The caller will perform the freeing operation. */
return false;
}
+}
+}
libc_hidden_def (__libc_dynarray_finalize)
diff --git a/lib/malloc/dynarray_resize.c b/lib/malloc/dynarray_resize.c
index 92bbddd..6eab7f5 100644
--- a/lib/malloc/dynarray_resize.c
+++ b/lib/malloc/dynarray_resize.c
@@ -37,6 +37,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
expected to provide the final size of the array, so there is no
over-allocation here. */
+{
size_t new_size_bytes;
if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes))
{
@@ -44,6 +45,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
__set_errno (ENOMEM);
return false;
}
+{
void *new_array;
if (list->array == scratch)
{
@@ -61,4 +63,6 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
list->used = size;
return true;
}
+}
+}
libc_hidden_def (__libc_dynarray_resize)
diff --git a/lib/malloc/dynarray_resize_clear.c b/lib/malloc/dynarray_resize_clear.c
index 99c2cc8..99f1591 100644
--- a/lib/malloc/dynarray_resize_clear.c
+++ b/lib/malloc/dynarray_resize_clear.c
@@ -27,9 +27,11 @@ __libc_dynarray_resize_clear (struct dynarray_header *list, size_t size,
if (!__libc_dynarray_resize (list, size, scratch, element_size))
return false;
/* __libc_dynarray_resize already checked for overflow. */
+{
char *array = list->array;
memset (array + (old_size * element_size), 0,
(size - old_size) * element_size);
return true;
}
+}
libc_hidden_def (__libc_dynarray_resize_clear)
diff --git a/lib/malloc/scratch_buffer_set_array_size.c b/lib/malloc/scratch_buffer_set_array_size.c
index e2b9f31..8375ff3 100644
--- a/lib/malloc/scratch_buffer_set_array_size.c
+++ b/lib/malloc/scratch_buffer_set_array_size.c
@@ -48,6 +48,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
/* Discard old buffer. */
scratch_buffer_free (buffer);
+{
char *new_ptr = malloc (new_length);
if (new_ptr == NULL)
{
@@ -61,4 +62,5 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
buffer->length = new_length;
return true;
}
+}
libc_hidden_def (__libc_scratch_buffer_set_array_size)
diff --git a/lib/md5.c b/lib/md5.c
index e7eeeaa..afcf927 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -144,19 +144,20 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
int
md5_stream (FILE *stream, void *resblock)
{
+ char *buffer;
+ struct md5_ctx ctx;
+ size_t sum;
switch (afalg_stream (stream, "md5", resblock, MD5_DIGEST_SIZE))
{
case 0: return 0;
case -EIO: return 1;
}
- char *buffer = malloc (BLOCKSIZE + 72);
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
- struct md5_ctx ctx;
md5_init_ctx (&ctx);
- size_t sum;
/* Iterate over full file contents. */
while (1)
diff --git a/lib/mktime.c b/lib/mktime.c
index 2c7cd7b..00d801c 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -273,6 +273,8 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
long_int t1 = (*t < mktime_min ? mktime_min
: *t <= mktime_max ? *t : mktime_max);
struct tm *r = convert_time (convert, t1, tp);
+ long_int bad, ok;
+ struct tm oktm;
if (r)
{
*t = t1;
@@ -281,9 +283,9 @@ ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *),
if (errno != EOVERFLOW)
return NULL;
- long_int bad = t1;
- long_int ok = 0;
- struct tm oktm; oktm.tm_sec = -1;
+ bad = t1;
+ ok = 0;
+ oktm.tm_sec = -1;
/* BAD is a known out-of-range value, and OK is a known in-range one.
Use binary search to narrow the range between BAD and OK until
@@ -365,6 +367,7 @@ __mktime_internal (struct tm *tp,
int negative_offset_guess;
int sec_requested = sec;
+ long_int t0, t, t1, t2;
if (LEAP_SECONDS_POSSIBLE)
{
@@ -380,18 +383,19 @@ __mktime_internal (struct tm *tp,
time. */
INT_SUBTRACT_WRAPV (0, off, &negative_offset_guess);
- long_int t0 = ydhms_diff (year, yday, hour, min, sec,
+ t0 = ydhms_diff (year, yday, hour, min, sec,
EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0,
negative_offset_guess);
- long_int t = t0, t1 = t0, t2 = t0;
+ t = t0, t1 = t0, t2 = t0;
/* Repeatedly use the error to improve the guess. */
while (true)
{
+ long_int dt;
if (! ranged_convert (convert, &t, &tm))
return -1;
- long_int dt = tm_diff (year, yday, hour, min, sec, &tm);
+ dt = tm_diff (year, yday, hour, min, sec, &tm);
if (dt == 0)
break;
@@ -529,8 +533,9 @@ __mktime64 (struct tm *tp)
__tzset ();
# if defined _LIBC || NEED_MKTIME_WORKING
- static mktime_offset_t localtime_offset;
+{ static mktime_offset_t localtime_offset;
return __mktime_internal (tp, __localtime64_r, &localtime_offset);
+}
# else
# undef mktime
return mktime (tp);
diff --git a/lib/readlink.c b/lib/readlink.c
index c4b635c..26e2242 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -69,6 +69,7 @@ rpl_readlink (char const *file, char *buf, size_t bufsize)
}
# endif /* READLINK_TRAILING_SLASH_BUG */
+{
ssize_t r = readlink (file, buf, bufsize);
# if READLINK_TRUNCATE_BUG
@@ -100,5 +101,6 @@ rpl_readlink (char const *file, char *buf, size_t bufsize)
return r;
}
+}
#endif /* HAVE_READLINK */
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 0c31b0e..0d51610 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -3091,6 +3091,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
}
#endif
+{
re_token_t br_token;
re_bitset_ptr_t sbcset;
#ifdef RE_ENABLE_I18N
@@ -3386,6 +3387,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
#endif /* RE_ENABLE_I18N */
return NULL;
}
+}
/* Parse an element in the bracket expression. */
@@ -3706,7 +3708,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
#endif
/* Build a tree for simple bracket. */
- re_token_t br_token = { .type = SIMPLE_BRACKET, .opr.sbcset = sbcset };
+{
+ re_token_t br_token = { .type = SIMPLE_BRACKET };
+ br_token.opr.sbcset = sbcset;
tree = create_token_tree (dfa, NULL, NULL, &br_token);
if (__glibc_unlikely (tree == NULL))
goto build_word_op_espace;
@@ -3744,6 +3748,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
*err = REG_ESPACE;
return NULL;
}
+}
/* This is intended for the expressions like "a{1,3}".
Fetch a number from 'input', and return the number.
diff --git a/lib/regexec.c b/lib/regexec.c
index 15dc57b..af7bbbf 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1400,6 +1400,7 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
free_fail_stack_return (fs);
return REG_ESPACE;
}
+{
regmatch_t *prev_idx_match = regmatch_list_begin (&prev_match);
memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch);
@@ -1460,6 +1461,7 @@ set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
regmatch_list_free (&prev_match);
return free_fail_stack_return (fs);
}
+}
static reg_errcode_t
free_fail_stack_return (struct re_fail_stack_t *fs)
diff --git a/lib/sha1.c b/lib/sha1.c
index 612d46d..10e4843 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -132,19 +132,20 @@ sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
int
sha1_stream (FILE *stream, void *resblock)
{
+ char *buffer;
+ struct sha1_ctx ctx;
+ size_t sum;
switch (afalg_stream (stream, "sha1", resblock, SHA1_DIGEST_SIZE))
{
case 0: return 0;
case -EIO: return 1;
}
- char *buffer = malloc (BLOCKSIZE + 72);
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
- struct sha1_ctx ctx;
sha1_init_ctx (&ctx);
- size_t sum;
/* Iterate over full file contents. */
while (1)
diff --git a/lib/sha256.c b/lib/sha256.c
index 129d64b..499c377 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -182,19 +182,20 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
ssize_t hashlen, void (*init_ctx) (struct sha256_ctx *),
void *(*finish_ctx) (struct sha256_ctx *, void *))
{
+ char *buffer;
+ struct sha256_ctx ctx;
+ size_t sum;
switch (afalg_stream (stream, alg, resblock, hashlen))
{
case 0: return 0;
case -EIO: return 1;
}
- char *buffer = malloc (BLOCKSIZE + 72);
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
- struct sha256_ctx ctx;
init_ctx (&ctx);
- size_t sum;
/* Iterate over full file contents. */
while (1)
diff --git a/lib/sha512.c b/lib/sha512.c
index 4ac3fa3..3324d94 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -183,19 +183,20 @@ shaxxx_stream (FILE *stream, char const *alg, void *resblock,
ssize_t hashlen, void (*init_ctx) (struct sha512_ctx *),
void *(*finish_ctx) (struct sha512_ctx *, void *))
{
+ char *buffer;
+ struct sha512_ctx ctx;
+ size_t sum;
switch (afalg_stream (stream, alg, resblock, hashlen))
{
case 0: return 0;
case -EIO: return 1;
}
- char *buffer = malloc (BLOCKSIZE + 72);
+ buffer = malloc (BLOCKSIZE + 72);
if (!buffer)
return 1;
- struct sha512_ctx ctx;
init_ctx (&ctx);
- size_t sum;
/* Iterate over full file contents. */
while (1)
diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c
index 641e921..ec7a8af 100644
--- a/lib/spawn-pipe.c
+++ b/lib/spawn-pipe.c
@@ -444,6 +444,7 @@ create_pipe (const char *progname,
#else
+{
/* Unix API. */
int ifd[2];
int ofd[2];
@@ -587,7 +588,7 @@ create_pipe (const char *progname,
if (pipe_stdin)
fd[1] = ofd[1];
return child;
-
+}
#endif
fail_with_errno:
diff --git a/lib/tempname.c b/lib/tempname.c
index ea759f4..3f162d1 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -85,9 +85,11 @@ random_bits (random_value var)
return r;
#if _LIBC || (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME)
/* Add entropy if getrandom did not work. */
+{
struct __timespec64 tv;
__clock_gettime64 (CLOCK_MONOTONIC, &tv);
var ^= tv.tv_nsec;
+}
#endif
return 2862933555777941757 * var + 3037000493;
}
@@ -287,7 +289,8 @@ try_tempname_len (char *tmpl, int suffixlen, void *args,
for (count = 0; count < attempts; ++count)
{
- for (size_t i = 0; i < x_suffix_len; i++)
+ size_t i;
+ for (i = 0; i < x_suffix_len; i++)
{
if (vdigits == 0)
{
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 4203f19..123b7db 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -69,11 +69,13 @@ xrealloc (void *p, size_t n)
return NULL;
}
+{
void *r = realloc (p, n);
if (!r && (n || (HAVE_GNU_REALLOC && !p)))
xalloc_die ();
return r;
}
+}
/* If P is null, allocate a block of at least *PN bytes; otherwise,
reallocate P so that it contains more than *PN bytes. *PN must be
diff --git a/src/cookies.c b/src/cookies.c
index f8b6644..3f2670f 100644
--- a/src/cookies.c
+++ b/src/cookies.c
@@ -740,6 +740,7 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
{
struct cookie *cookie;
cookies_now = time (NULL);
+{
char buf[1024], *tmp;
size_t pathlen = strlen(path);
@@ -825,6 +826,7 @@ cookie_handle_set_cookie (struct cookie_jar *jar,
if (tmp != buf)
xfree (tmp);
}
+}
/* Support for sending out cookies in HTTP requests, based on
previously stored cookies. Entry point is
diff --git a/src/ftp.c b/src/ftp.c
index ea7621e..5017af0 100644
--- a/src/ftp.c
+++ b/src/ftp.c
@@ -2606,6 +2606,8 @@ ftp_retrieve_glob (struct url *u, struct url *original_url,
{
struct fileinfo *f, *start;
uerr_t res;
+ int (*matcher) (const char *, const char *, int);
+ int (*cmp) (const char *, const char *);
con->cmd |= LEAVE_PENDING;
@@ -2614,7 +2616,7 @@ ftp_retrieve_glob (struct url *u, struct url *original_url,
return res;
// Set the function used for glob matching.
- int (*matcher) (const char *, const char *, int)
+ matcher
= opt.ignore_case ? fnmatch_nocase : fnmatch;
// Set the function used to compare strings
@@ -2628,10 +2630,10 @@ ftp_retrieve_glob (struct url *u, struct url *original_url,
* the senseless type cast clears the complaint, and looks
* harmless.
*/
- int (*cmp) (const char *, const char *)
+ cmp
= opt.ignore_case ? strcasecmp : (int (*)())strcmp;
#else /* def __VMS */
- int (*cmp) (const char *, const char *)
+ cmp
= opt.ignore_case ? strcasecmp : strcmp;
#endif /* def __VMS [else] */
diff --git a/src/main.c b/src/main.c
index 48b84fa..5c99e28 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1380,11 +1380,12 @@ main (int argc, char **argv)
bool use_userconfig = false;
bool noconfig = false;
bool append_to_log = false;
+ double start_time;
cleaned_up = 0; /* do cleanup later */
timer = ptimer_new ();
- double start_time = ptimer_measure (timer);
+ start_time = ptimer_measure (timer);
total_downloaded_bytes = 0;
program_name = argv[0];
diff --git a/src/openssl.c b/src/openssl.c
index 33f4273..cd5d914 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -347,6 +347,7 @@ ssl_init (void)
* intermediate CA to clients, can be used as a trust anchor without
* the entire IdentTrust PKI.
*/
+{
X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
if (param)
{
@@ -366,6 +367,7 @@ ssl_init (void)
logprintf(LOG_NOTQUIET, _("OpenSSL: Failed to allocate verification param\n"));
/* We continue on error */
}
+}
#endif
if (opt.crl_file)
@@ -567,7 +569,7 @@ openssl_read_peek (int fd, char *buf, int bufsize, void *arg, double timeout, ss
NONBLOCK_DECL \
int timed_out = 0; \
FD_SET_NONBLOCKED(_fd) \
- struct ptimer *timer = ptimer_new (); \
+ { struct ptimer *timer = ptimer_new (); \
if (timer == NULL) \
_ret = -1; \
else \
@@ -577,7 +579,7 @@ openssl_read_peek (int fd, char *buf, int bufsize, void *arg, double timeout, ss
#define TIMER_FREE(_fd) \
ptimer_destroy (timer); \
} \
- FD_SET_BLOCKED(_fd) \
+ } FD_SET_BLOCKED(_fd) \
if (timed_out) \
{ \
errno = ETIMEDOUT; \
diff --git a/src/progress.c b/src/progress.c
index deb3bce..37ecbe4 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -400,10 +400,12 @@ dot_update (void *progress, wgint howmuch, double dltime)
if (howmuch < 0)
howmuch = 0;
+{
struct dot_progress *dp = progress;
dp->accumulated += howmuch;
dp->dltime = dltime;
}
+}
static void
dot_draw (void *progress)
@@ -1375,7 +1377,8 @@ bar_set_params (const char *params)
#endif
if (params)
{
- for (const char *param = params; *param; )
+ const char *param;
+ for (param = params; *param; )
{
if (!strncmp (param, "force", 5))
current_impl_locked = 1;
--
2.30.0