summaryrefslogtreecommitdiff
path: root/CCache
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-26 18:18:55 +0000
commit60af317956714c23452c1593575511e0577e08ac (patch)
tree82ba0cca1f27d0e86c90dc967fbb10002c94d8f2 /CCache
parent637e2976721ab69936d408e7f7044746e79264fe (diff)
downloadswig-60af317956714c23452c1593575511e0577e08ac.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
Diffstat (limited to 'CCache')
-rw-r--r--CCache/ccache.c16
-rw-r--r--CCache/mdfour.c4
2 files changed, 11 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)