-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined Behavior: strncpy
from NULL
#2596
Comments
Do you see any other log before the crash? I think |
Here's a command to reproduce the issue starting from a fresh debian:bookworm-slim container: apt -y update && apt -y install clang git make python3-dev && git clone https://github.com/unbit/uwsgi && cd uwsgi && make -j$(nproc) CC=clang CFLAGS='-fsanitize=undefined' LDFLAGS='-fsanitize=undefined' && echo 'def application(env, sr): sr("200 OK", []); return [b""]' > server.py && ./uwsgi --http=127.0.0.1:8080 --wsgi-file='server.py' Here's the uwsgi output:
|
Stepping through the function, the call to |
Steps to reproduce:
strncpy
fromNULL
. It is always undefined behavior to execute astrncpy
fromNULL
, even whenn==0
.Suggested patch
Add a check around the
strncpy
call atplugins/python/pyloader.c:100
to prevent making calls whenn==0
.The text was updated successfully, but these errors were encountered: