There are clang warnings, that point to bugs:
src/tools/env.c:
Warning:
src/tools/env.c:786:13: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
786 | if(p=lowercase_filename+strlen(lowercase_filename)-strlen(" (deleted)"))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/tools/env.c:786:13: note: place parentheses around the assignment to silence this warning
786 | if(p=lowercase_filename+strlen(lowercase_filename)-strlen(" (deleted)"))
| ^
| ( )
src/tools/env.c:786:13: note: use '==' to turn this assignment into an equality comparison
786 | if(p=lowercase_filename+strlen(lowercase_filename)-strlen(" (deleted)"))
| ^
| ==
Code:
L785-789 in function RecordEnvMappings
// memfd, first remove the (deleted) at the end
char* p = strstr(lowercase_filename, " (deleted)");
if(p=lowercase_filename+strlen(lowercase_filename)-strlen(" (deleted)"))
*p = 0;
// add the "/fd" at the end to differenciate between memfd
char* new_name = box_calloc(1, strlen(lowercase_filename)+100);
Expected behaviour:
The function removes the suffix if present
Actual behaviour:
The function always removes the last 10 bytes.
Also, the +100 bytes buffer on line 788 seems excessive for %d. INT_MAX is 19 chars on 64bit.
wrappedlibc.c:
Warning:
src/wrapped/wrappedlibc.c:2046:46: warning: format specifies type 'char *' but the argument has type 'char (*)[4096]' [-Wformat]
2046 | if(sscanf(path, "/proc/%d/%s", &pid, &p)==2)
| ~~ ^~
src/wrapped/wrappedlibc.c:2047:16: warning: address of array 'p' will always evaluate to 'true' [-Wpointer-bool-conversion]
2047 | if(p && !strcmp(p, w))
| ^ ~~
Code:
L241-2051
if(sscanf(path, "/proc/%d/%s", &pid, &p)==2)
if(p && !strcmp(p, w))
return pid;
L2098:
int pid = (ret>0)?isProcAny(path, "exe"):0;
Expected behaviour:
Return the pid when the provided path is a link to an executable
Actual behaviour:
Always returns the pid (p is always true)
Also p is already a pointer
wrappedlibc.c:
Warning:
src/wrapped/wrappedlibc.c:2128:47: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
2128 | sprintf(cwd_name, "/proc/%d/cwd");
| ~^
Issue:
The pid is missing:
There are clang warnings, that point to bugs:
src/tools/env.c:
Warning:
Code:
L785-789 in function RecordEnvMappings
Expected behaviour:
The function removes the suffix if present
Actual behaviour:
The function always removes the last 10 bytes.
Also, the +100 bytes buffer on line 788 seems excessive for
%d. INT_MAX is 19 chars on 64bit.wrappedlibc.c:
Warning:
Code:
L241-2051
L2098:
Expected behaviour:
Return the pid when the provided path is a link to an executable
Actual behaviour:
Always returns the pid (p is always true)
Also p is already a pointer
wrappedlibc.c:
Warning:
Issue:
The pid is missing: