diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-09-28 01:04:36 +0000 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-09-28 01:04:36 +0000 |
commit | 2ba5edfcb5db574b79afb4c1c1f3816e1600bb75 (patch) | |
tree | a1c43a95df51f5f06e38d920eb4fd5d0bc919cf8 /user/iperf3/time64.patch | |
parent | 4ac3b96ccca4c0351861ae3d0c0e0bc570e932ec (diff) | |
download | packages-2ba5edfcb5db574b79afb4c1c1f3816e1600bb75.tar.gz packages-2ba5edfcb5db574b79afb4c1c1f3816e1600bb75.tar.bz2 packages-2ba5edfcb5db574b79afb4c1c1f3816e1600bb75.tar.xz packages-2ba5edfcb5db574b79afb4c1c1f3816e1600bb75.zip |
user/iperf3: Fix time64 issue
Diffstat (limited to 'user/iperf3/time64.patch')
-rw-r--r-- | user/iperf3/time64.patch | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/user/iperf3/time64.patch b/user/iperf3/time64.patch new file mode 100644 index 000000000..84806dc20 --- /dev/null +++ b/user/iperf3/time64.patch @@ -0,0 +1,75 @@ +From f19d964fd91a6f2b26aa70b6caa1290c3f6fdbc7 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" <AWilcox@Wilcox-Tech.com> +Date: Sun, 27 Sep 2020 19:56:15 -0500 +Subject: [PATCH] auth: Ensure 64-bit time_t works on 32-bit systems + +On a 32-bit PowerPC Linux system using musl libc (with 64-bit time_t), +the t_auth test fails because `long` is not the same type as `time_t`. + +This patch uses an int64_t temporary value, which can be truncated to +32-bit if necessary. +--- + src/iperf_auth.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/iperf_auth.c b/src/iperf_auth.c +index eb4610f..a824deb 100644 +--- a/src/iperf_auth.c ++++ b/src/iperf_auth.c +@@ -35,6 +35,8 @@ + #define _WITH_GETLINE + #include <stdio.h> + #include <termios.h> ++#include <inttypes.h> ++#include <stdint.h> + + #if defined(HAVE_SSL) + +@@ -45,7 +47,7 @@ + #include <openssl/buffer.h> + #include <openssl/err.h> + +-const char *auth_text_format = "user: %s\npwd: %s\nts: %ld"; ++const char *auth_text_format = "user: %s\npwd: %s\nts: %"PRId64; + + void sha256(const char *string, char outputBuffer[65]) + { +@@ -291,7 +293,7 @@ int encode_auth_setting(const char *username, const char *password, EVP_PKEY *pu + if (text == NULL) { + return -1; + } +- snprintf(text, text_len, auth_text_format, username, password, utc_seconds); ++ snprintf(text, text_len, auth_text_format, username, password, (int64_t)utc_seconds); + + unsigned char *encrypted = NULL; + int encrypted_len; +@@ -309,7 +311,8 @@ int encode_auth_setting(const char *username, const char *password, EVP_PKEY *pu + int decode_auth_setting(int enable_debug, const char *authtoken, EVP_PKEY *private_key, char **username, char **password, time_t *ts){ + unsigned char *encrypted_b64 = NULL; + size_t encrypted_len_b64; +- Base64Decode(authtoken, &encrypted_b64, &encrypted_len_b64); ++ int64_t utc_seconds; ++ Base64Decode(authtoken, &encrypted_b64, &encrypted_len_b64); + + unsigned char *plaintext = NULL; + int plaintext_len; +@@ -331,7 +334,7 @@ int decode_auth_setting(int enable_debug, const char *authtoken, EVP_PKEY *priva + return -1; + } + +- int rc = sscanf((char *) plaintext, auth_text_format, s_username, s_password, ts); ++ int rc = sscanf((char *) plaintext, auth_text_format, s_username, s_password, &utc_seconds); + if (rc != 3) { + free(s_password); + free(s_username); +@@ -344,6 +347,7 @@ int decode_auth_setting(int enable_debug, const char *authtoken, EVP_PKEY *priva + } + *username = s_username; + *password = s_password; ++ *ts = (time_t)utc_seconds; + OPENSSL_free(plaintext); + return (0); + } +-- +2.25.4 + |