From c4ecde031a4c957876320b1d1c1860360ab22323 Mon Sep 17 00:00:00 2001 From: Ben Kallus Date: Mon, 1 Jan 2024 13:00:39 -0500 Subject: [PATCH] Avoid strncpy from null in pyloader --- plugins/python/pyloader.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/python/pyloader.c b/plugins/python/pyloader.c index 3a1465d67..dc816fa10 100644 --- a/plugins/python/pyloader.c +++ b/plugins/python/pyloader.c @@ -97,7 +97,9 @@ int init_uwsgi_app(int loader, void *arg1, struct wsgi_request *wsgi_req, PyThre memset(wi, 0, sizeof(struct uwsgi_app)); wi->modifier1 = python_plugin.modifier1; wi->mountpoint_len = wsgi_req->appid_len < 0xff ? wsgi_req->appid_len : (0xff-1); - strncpy(wi->mountpoint, wsgi_req->appid, wi->mountpoint_len); + if (wi->mountpoint_len > 0) { + strncpy(wi->mountpoint, wsgi_req->appid, wi->mountpoint_len); + } // dynamic chdir ? if (wsgi_req->chdir_len > 0) {