summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-26 17:46:09 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-11-28 07:45:38 +0000
commit6a2ed5120e4b68bca59f9a8c86661c8f86279630 (patch)
tree6e55a8e43a58f790bc432a19c32e0fd975f87784
parentc8fd30bde2740417d611a47cee782bc947fb2a9f (diff)
downloadswig-6a2ed5120e4b68bca59f9a8c86661c8f86279630.tar.gz
Fix UBSAN errors in ccache-swig
ccache.c:738:18: runtime error: null pointer passed as argument 1, which is declared to never be null Fixes stderr redirect in testname CCACHE_CPP2, when the CCACHE_CPP2 environment variable is defined. mdfour.c:91:20: runtime error: left shift of 139 by 24 places cannot be represented in type 'int' Looks like this brings some stability to the md4 hash calculation. Closes #2449 Conflicts: CHANGES.current
-rw-r--r--CCache/ccache.c16
-rw-r--r--CCache/mdfour.c4
-rw-r--r--CHANGES.current4
3 files changed, 15 insertions, 9 deletions
diff --git a/CCache/ccache.c b/CCache/ccache.c
index c5c510388..a28d38324 100644
--- a/CCache/ccache.c
+++ b/CCache/ccache.c
@@ -735,13 +735,15 @@ static void from_cache(int first)
}
/* send the cpp stderr, if applicable */
- fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY);
- if (fd_cpp_stderr != -1) {
- copy_fd(fd_cpp_stderr, 2);
- close(fd_cpp_stderr);
- unlink(cpp_stderr);
- free(cpp_stderr);
- cpp_stderr = NULL;
+ if (cpp_stderr) {
+ fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY);
+ if (fd_cpp_stderr != -1) {
+ copy_fd(fd_cpp_stderr, 2);
+ close(fd_cpp_stderr);
+ unlink(cpp_stderr);
+ free(cpp_stderr);
+ cpp_stderr = NULL;
+ }
}
/* send the stderr */
diff --git a/CCache/mdfour.c b/CCache/mdfour.c
index b098e0215..5b304852b 100644
--- a/CCache/mdfour.c
+++ b/CCache/mdfour.c
@@ -88,8 +88,8 @@ static void copy64(uint32 *M, const unsigned char *in)
int i;
for (i=0;i<16;i++)
- M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
- (in[i*4+1]<<8) | (in[i*4+0]<<0);
+ M[i] = ((uint32)in[i*4+3]<<24) | ((uint32)in[i*4+2]<<16) |
+ ((uint32)in[i*4+1]<<8) | ((uint32)in[i*4+0]<<0);
}
static void copy4(unsigned char *out,uint32 x)
diff --git a/CHANGES.current b/CHANGES.current
index 37d8d90e9..b463a9d89 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.1 (in progress)
===========================
+2022-11-26: wsfulton
+ #2449 Fix undefined behaviour in ccache-swig calculating md4 hashes and possibly
+ also handling errors when CCACHE_CPP2 is set.
+
2022-11-25: wsfulton
#961 Fix syntax error parsing unnamed template parameters with a default value.