1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2026-02-05 18:20:32 +03:00

Compare commits

...

4 Commits

Author SHA1 Message Date
1411d4ceb4 Merge pull request #2217 from synqa/fix-preserve-errno
Fix preserve errno in SIGCHLD signal handler
2026-02-05 15:46:13 +01:00
a3176175f9 Merge pull request #2216 from synqa/fix-ub-leftshift
Fix undefined behavior of left shift
2026-02-05 15:13:46 +01:00
88af7986b4 Fix preserve errno in SIGCHLD signal handler
Signal handler may interrupt code that depends on errno, and waitpid()
may modify errno, therefore, errno must be saved and restored before
returning.
2026-02-05 18:51:58 +09:00
38f102e2e7 Fix undefined behavior of left shift
Left shifting UCHAR promotes it to a signed integer. When the
value is >= 128 and shifted by 24, the result sets the sign bit,
causing undefined behavior. Fixes it by explicit casting to UINT.
2026-02-05 18:48:01 +09:00
2 changed files with 5 additions and 1 deletions

View File

@ -4761,7 +4761,7 @@ static void MY_SHA0_Transform(MY_SHA0_CTX* ctx) {
UCHAR* p = ctx->buf;
int t;
for(t = 0; t < 16; ++t) {
UINT tmp = *p++ << 24;
UINT tmp = (UINT)*p++ << 24;
tmp |= *p++ << 16;
tmp |= *p++ << 8;
tmp |= *p++;

View File

@ -2140,9 +2140,13 @@ void UnixMemoryFree(void *addr)
// SIGCHLD handler
void UnixSigChldHandler(int sig)
{
int old_errno = errno;
// Recall the zombie processes
while (waitpid(-1, NULL, WNOHANG) > 0);
signal(SIGCHLD, UnixSigChldHandler);
errno = old_errno;
}
// Disable core dump