From patchwork Mon Dec 14 22:05:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Germann X-Patchwork-Id: 1416205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13d; helo=mail-lf1-x13d.google.com; envelope-from=swupdate+bncbdpppp7kyilbbqwd377akgqeuoax7ui@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=linutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=T7Ic304P; dkim-atps=neutral Received: from mail-lf1-x13d.google.com (mail-lf1-x13d.google.com [IPv6:2a00:1450:4864:20::13d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CvwSt1gVTz9s0b for ; Tue, 15 Dec 2020 09:06:02 +1100 (AEDT) Received: by mail-lf1-x13d.google.com with SMTP id a14sf8688566lfo.5 for ; Mon, 14 Dec 2020 14:06:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1607983555; cv=pass; d=google.com; s=arc-20160816; b=pMOzxqGvpVHJxeE/BG2aHVKDJmqTUKn4l7GdFSP+LwBDPvjN12AD9c/BvFlOpjNuvc h5869H+P6o8KEw+q7tsoLpJCFF+/k08Dohqi/SwGwuK213KnKtCy4qiTOzZAOXJTTXWe ZgFTIfGYMG72vMRjRmRlfPIAW5G6f5it0JfTqvpzSxd27yUW5BnBv2x23e03gwhhlxCU jWKI/r+Q8wCeT8RFxhnm4f2hGxPRZCrJ/FiVfcIsL4wq6uVR4KKyHctxK36F37mwoeTN apgFt53lsxzhgcZU0bd1UvKgWMvlOjPEX6pifh3aGwpC33CWoOK+l1eZXx3Si8Ipis9L 9XWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=RO3Cn1BJV9SAl6dH6ZToZbom94N9vTN/ToHhF/M6ywE=; b=FUSMxzBVGSzXUT12nttQW7WM7nL0h/Vc4WHnTqfrqETNc1xQUwyBBzvjb13lSexAc6 AIR6av8rVUN4mq8ok1IIwLjmcXgJM0R24f0f2pMMfXv1L8Vlbyl+XZvG84q8VZgZe0ks BygEn/akNkSVh0sNH2Ed2/4AgmnUW5+VZnzQkR9PlNfMB7XZLnbMzuSd7G5RPwvEnpFx O+lJei8hsQbD/SM21b2LdwEpRba7RQCc8qlAYPUxRndIP2ownk6r88cRqyKdT0PgPGS6 5yRgyMU+1AeYxClgcGgsYop3SSthkRYdXXowgKYyxB+zO5AQlQ6Mh2cYbF5M+WqkNBFv MD2Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jaTJYpl5; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of bage@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bage@linutronix.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=RO3Cn1BJV9SAl6dH6ZToZbom94N9vTN/ToHhF/M6ywE=; b=T7Ic304PcreX9ISQ8kp48VoBRnuoB7wldJaXw7gE1vtQBhTfvE5W8Ypo0RYrB7iMsT QA5reqN1Ro7efxI6CmaoMHnvF46Im+lbfaPznRrpCTQgWBfn8JOunetM8SNLYPgrGLDb YVekYhe/ZW7+zFowKSAPVvAzw+QeHkKeuEBYI2aOW2KiuhaMBW4/g1QTyKALagzNfm41 vTMNAsBnzAXKQpc2EJ0WqFmDrNpyhkZuQZdtw4IGp7DVJ1mw8naTOfFXAUHSYf9ZVStf 1m4iKt9Gv39ep1aAXIsLUIlT7GK4Q8SL64EBLaqx6mfpA2khatwocJ/ClXsLC3vrBELs u10Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=RO3Cn1BJV9SAl6dH6ZToZbom94N9vTN/ToHhF/M6ywE=; b=f4YB8jmn1txGp2CCY7zp2aa+dQ7KivRdINz9z/MAj2UKRQ88cLbuInqPWK6nfI7hDV uhyc2dUEKHzlWl95iz3uqXDUZqQgLeqFAVFFxGmQnpLGnTvqE4CrPhPPw6m6ClrfcDnb 1qhqlFmAVZNxEysZP/H8rnPisVspWmlpIn48EqsX6X+HY3j4jcWOR6JNWyF8U25qp0/4 JMQP1/ByGeOW9f9sSM4mQvL5tC9TeRPXj8oeefE8cq2c2/TjZ+KZ5Evlwu/vXW9vw5y5 NhMoTszx5o3sxg8D1DhCh4ObAtvN+OLGFFYYcbRX9gaRbEWd3v94xZmWRcaw/tFwn5qO VFYw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM531UXXvN0mYgNXz+Vg8KeG+N2j9lNyp4xr5/jG3p65a0YBYwizwM pdGrxGLEOKUzjXLYrVb7yqY= X-Google-Smtp-Source: ABdhPJzjYYLUJCJy6NZTiwKCl/AETpFfVou4OjTq3XhmHIO1MsAUqjPGknDKcWrqdw/EuZeh86ZOMQ== X-Received: by 2002:ac2:5689:: with SMTP id 9mr11018217lfr.175.1607983554768; Mon, 14 Dec 2020 14:05:54 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:bc2a:: with SMTP id b42ls3501086ljf.2.gmail; Mon, 14 Dec 2020 14:05:53 -0800 (PST) X-Received: by 2002:a2e:b896:: with SMTP id r22mr10285324ljp.442.1607983553475; Mon, 14 Dec 2020 14:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607983553; cv=none; d=google.com; s=arc-20160816; b=NHJqDiG3BGpBKkXIgKaGlc3aPqd3PtAkNAl+LXpaK8HmomCl63qo/D7jyUksu+ISBP H830UfzkgQ9PfQ9J2dmPQ412N0/iL4W69VpFH6Ax5Y9PAxtKrzUIf58Bcx7sLkjSIlAK 1w1hCDgRvK6nxT2U6cqr6pyHBc3eET2d7FyIgyFp/8j6l0swxspq5NUviyB5n0Z7Dmyd 7tQg33sA8HL4eTocYg0WpWHV8dha/4M1l/ANaE9xg4oAchlzBKCjuo2tXhvhh9sLIoRQ NsNEc3cWIDtJ/fIBMlcx44gOiNPrfVQIgQ9+UCj1RznobMGxPUk6mN1sAQNdzmREDdtD B21g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dkim-signature:dkim-signature:from; bh=Fk/T3GChoe02WXKs5xKFdH3WL0SzZNTszB1nBgnftoA=; b=tV6WjM6xIMeoYwqPP/BDcB0VTiU3Hob7/M+rFk59PsqlwIzXSXI2xoxGqkQlbknhHB YqXRT/B6B8OvRRjCy/7vXPn3lOtyR2Y2HLlof2B6BG0iFLSINmLmr4yPEUURxFUpz0YE vMi8Tx3zIiQkTm/lNa2IbIymkaW5wwfGKf5Wi1NAG3gWr3j/cKVjZlx28gDFyNhexk+e 9D78S835y9txgeRdXCZgxGRhzq9VHPglsimi9detbm8uFdLnOE0kN03sHG3mxpSdDlfk Yj7KXHTbh8n7aD4J7m5USe8n/j834az8aVNOOyoOh/Sp3swRcThglRkaR1LmWhpcKfjs koaA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jaTJYpl5; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of bage@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bage@linutronix.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from galois.linutronix.de (Galois.linutronix.de. [193.142.43.55]) by gmr-mx.google.com with ESMTPS id h21si769763ljj.6.2020.12.14.14.05.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Dec 2020 14:05:53 -0800 (PST) Received-SPF: pass (google.com: domain of bage@linutronix.de designates 193.142.43.55 as permitted sender) client-ip=193.142.43.55; From: bage@linutronix.de To: swupdate@googlegroups.com Cc: Bastian Germann Subject: [swupdate] [PATCH] swuforward-ws.c: Prevent segfault in TEXTRANGE_TO_STR Date: Mon, 14 Dec 2020 23:05:45 +0100 Message-Id: <20201214220545.29488-1-bage@linutronix.de> MIME-Version: 1.0 X-Original-Sender: bage@linutronix.de X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=jaTJYpl5; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of bage@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bage@linutronix.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: Bastian Germann TEXTRANGE_TO_STR is called with uri.portText which might contain {NULL,NULL} if there is no port information in a swuforward URL. In that case, evaluate to NULL instead of calling substring. Signed-off-by: Bastian Germann Acked-by: Stefano Babic --- handlers/swuforward-ws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/swuforward-ws.c b/handlers/swuforward-ws.c index c2dbb5e..28ebba7 100644 --- a/handlers/swuforward-ws.c +++ b/handlers/swuforward-ws.c @@ -33,7 +33,7 @@ struct wsconn { struct curlconn *conn; /* Back pointer to main structure */ }; -#define TEXTRANGE_TO_STR(f) (substring(f.first, 0, f.afterLast - f.first)) +#define TEXTRANGE_TO_STR(f) (f.first == NULL ? NULL : substring(f.first, 0, f.afterLast - f.first)) static int callback_ws_swupdate(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)