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 */ /* send the cpp stderr, if applicable */
fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY); if (cpp_stderr) {
if (fd_cpp_stderr != -1) { fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY);
copy_fd(fd_cpp_stderr, 2); if (fd_cpp_stderr != -1) {
close(fd_cpp_stderr); copy_fd(fd_cpp_stderr, 2);
unlink(cpp_stderr); close(fd_cpp_stderr);
free(cpp_stderr); unlink(cpp_stderr);
cpp_stderr = NULL; free(cpp_stderr);
cpp_stderr = NULL;
}
} }
/* send the stderr */ /* send the stderr */

View file

@ -88,8 +88,8 @@ static void copy64(uint32 *M, const unsigned char *in)
int i; int i;
for (i=0;i<16;i++) for (i=0;i<16;i++)
M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | M[i] = ((uint32)in[i*4+3]<<24) | ((uint32)in[i*4+2]<<16) |
(in[i*4+1]<<8) | (in[i*4+0]<<0); ((uint32)in[i*4+1]<<8) | ((uint32)in[i*4+0]<<0);
} }
static void copy4(unsigned char *out,uint32 x) 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) 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 2022-11-26: wsfulton
#1589 #1590 Slightly better decltype() support for expressions, such as: #1589 #1590 Slightly better decltype() support for expressions, such as: