getenv() returns NULL on non-existing variables. Replace result with empty string to avoid doing strlen() on a NULL pointer. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- common/ratp/getenv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/ratp/getenv.c b/common/ratp/getenv.c index 7b38d2e363..9617ab1b43 100644 --- a/common/ratp/getenv.c +++ b/common/ratp/getenv.c @@ -32,6 +32,9 @@ static int ratp_cmd_getenv(const struct ratp_bb *req, int req_len, value = getenv(varname); free(varname); + if (!value) + value = ""; + dlen = strlen(value); *rsp_len = sizeof(struct ratp_bb) + dlen; -- 2.30.2