wget: fix hsts time
authorHuangbin Zhan <zhanhb88@gmail.com>
Mon, 8 Nov 2021 20:16:56 +0000 (04:16 +0800)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Wed, 27 Sep 2023 16:55:31 +0000 (18:55 +0200)
`time_t` on musl 1.2 is 64bit, while `long` is 32 bit. we will always get zero time with the original source on mips big endian.

Signed-off-by: Huangbin Zhan <zhanhb88@gmail.com>
(cherry picked from commit 09076512680b742ad369d6496bf9b6819a37af24)

net/wget/Makefile
net/wget/patches/100-fix-hsts-time.patch [new file with mode: 0644]

index 0206a6135ad64f1795dce81972fb54895ac52d4f..e250ab339ee969b289fded6d0f961224b08a3bf1 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=wget
 PKG_VERSION:=1.21.1
-PKG_RELEASE:=1
+PKG_RELEASE:=$(AUTORELEASE)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@GNU/$(PKG_NAME)
diff --git a/net/wget/patches/100-fix-hsts-time.patch b/net/wget/patches/100-fix-hsts-time.patch
new file mode 100644 (file)
index 0000000..964d295
--- /dev/null
@@ -0,0 +1,54 @@
+From: Huangbin Zhan <zhanhb88@gmail.com>
+Date: Tue, 9 Nov 2021 23:05:55 +0800
+Subject: [PATCH] hsts.c: fix timestamp reading and writing.
+
+Always get zero time on big endian 32bit OS with 64bit time_t such as mips_24kc_musl.
+---
+ src/hsts.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/src/hsts.c
++++ b/src/hsts.c
+@@ -280,7 +280,7 @@ hsts_read_database (hsts_store_t store,
+   char host[256];
+   int port;
+-  time_t created, max_age;
++  uintmax_t created, max_age;
+   int include_subdomains;
+   func = (merge_with_existing_entries ? hsts_store_merge : hsts_new_entry);
+@@ -293,15 +293,15 @@ hsts_read_database (hsts_store_t store,
+       if (*p == '#')
+         continue;
+-      items_read = sscanf (p, "%255s %d %d %lu %lu",
++      items_read = sscanf (p, "%255s %d %d %"SCNuMAX" %"SCNuMAX,
+                            host,
+                            &port,
+                            &include_subdomains,
+-                           (unsigned long *) &created,
+-                           (unsigned long *) &max_age);
++                           &created,
++                           &max_age);
+       if (items_read == 5)
+-        func (store, host, port, created, max_age, !!include_subdomains);
++        func (store, host, port, (time_t) created, (time_t) max_age, !!include_subdomains);
+     }
+   xfree (line);
+@@ -326,10 +326,10 @@ hsts_store_dump (hsts_store_t store, FIL
+       struct hsts_kh *kh = (struct hsts_kh *) it.key;
+       struct hsts_kh_info *khi = (struct hsts_kh_info *) it.value;
+-      if (fprintf (fp, "%s\t%d\t%d\t%lu\t%lu\n",
++      if (fprintf (fp, "%s\t%d\t%d\t%"PRIuMAX"\t%"PRIuMAX"\n",
+                    kh->host, kh->explicit_port, khi->include_subdomains,
+-                   (unsigned long) khi->created,
+-                   (unsigned long) khi->max_age) < 0)
++                   (uintmax_t) khi->created,
++                   (uintmax_t) khi->max_age) < 0)
+         {
+           logprintf (LOG_ALWAYS, "Could not write the HSTS database correctly.\n");
+           break;