Module Name: src Committed By: kamil Date: Tue Jul 3 22:38:34 UTC 2018
Modified Files: src/sys/sys: wait.h Log Message: Try to appease KUBSan in sys/sys/wait.h in W_EXITCODE() Cast return value that is stored as int to unsigned int in order to appease the << 8 operation. In case of a ret=-1, this cast is papering things over or replacing UB with an implementation specific behavior. There is a reverse operation with the same papering things over: WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff) No functional change intended. Detected with Kernel Undefined Behavior Sanitizer. Reported by <Harry Pantazis> To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/sys/wait.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/sys/wait.h diff -u src/sys/sys/wait.h:1.35 src/sys/sys/wait.h:1.36 --- src/sys/sys/wait.h:1.35 Thu Nov 10 18:35:17 2016 +++ src/sys/sys/wait.h Tue Jul 3 22:38:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: wait.h,v 1.35 2016/11/10 18:35:17 christos Exp $ */ +/* $NetBSD: wait.h,v 1.36 2018/07/03 22:38:33 kamil Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993, 1994 @@ -69,7 +69,7 @@ #define WCOREFLAG 0200 #define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG) -#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#define W_EXITCODE(ret, sig) ((unsigned int)(ret) << 8 | (sig)) #define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED) #define W_CONTCODE() (_WCONTINUED) #endif