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
This commit is contained in:
William S Fulton 2022-11-26 17:46:09 +00:00
commit 60af317956
3 changed files with 15 additions and 9 deletions

View file

@ -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 */

View file

@ -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)

View file

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (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-26: wsfulton
#1589 #1590 Slightly better decltype() support for expressions, such as: