From patchwork Sun Feb 18 03:36:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 874841 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q1ZSLSTi"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zkXd027y2z9ryg for ; Sun, 18 Feb 2018 14:37:20 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4766DB9124F; Sun, 18 Feb 2018 04:37:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Sun, 18 Feb 2018 04:37:08 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 94BA1B9115B for ; Sun, 18 Feb 2018 04:37:06 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. - helo: .mail-lf0-f68.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 18 Feb 2018 04:37:05 +0100 (CET) Received: by mail-lf0-f68.google.com with SMTP id v9so6863420lfa.11 for ; Sat, 17 Feb 2018 19:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IhO7kjA+RNXS41YAYsEDOozPo4gNMuZlrDCnWNTPT7I=; b=Q1ZSLSTi3FZVCHm88OfI9lPYmZ9ZPxv7hYA5QjTMk3aONwhO5nu3/ePqwZR3q8FMfC 7n7IsFg+CMTHi0Txvy3jn4IPGvpK/+9uLkLw72U3PrCJRiOkuUcQWi1WpKF63p08mbBD HD2sgDZYK8rC2wvvcR1zl7jciWRfdWkI+1Miu9Ri1bPq9uVUzj0ixEc9p75ZxZ0uE8Q0 oZYDb9JRZJljA/28XRB6p2JSwsxqvQ0FzzhfBpzv6K+xI58DfCQzqNezWLLf42q4Weeh 0yTIUsYEIp1GkaVVkx8Q00l4husci1v+C/EIQ3Q+gugWaVwP1mL8/VDu/0Rjunbe2fbj RotA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IhO7kjA+RNXS41YAYsEDOozPo4gNMuZlrDCnWNTPT7I=; b=oGXTE6AzagBGm+QcKBEMoo78PvLoU4kqsgd02GXMznSnzHRqlVh1H9o1eC44kTtGHo bQtQMu+uBLtZQT8NxixBcyE2OFyp7aHxHLOZ08dxQvCODf8VclrYJm7Ma73JO+u+ucm0 kHY3VsdQKwzbTx2fSEflSV0XFM+yKKCbHdUTGaI9sCIRzcaF5p7VVc8V4kb09EphA76y 7Mitj/3LnbBMfZzv6zaoSW9LPC3QVTCOLC3IEBWybrYvmTGPMH+WyPvwdl6SoJ0yTryN o2jWQWd+nrkURyWBAsJySQU3BigEWl299904Z/jDVNylv0G/T5Otqacof451Czm0J7fv iZUw== X-Gm-Message-State: APf1xPBQnjeWEsl2JwadB5kAkdUZvs/dN+vbRlrekl3h2V/mN/J+wehq NnkFuxyuVR5KegvnUp4oAuIOfQ== X-Google-Smtp-Source: AH8x224LNL9clJu9d7pzYvjaiHhRHw+l0DaCvsXCYtBUSs7NCNTK8N6+XKzFa8BU5NtsDmGDSIs5iw== X-Received: by 10.46.66.143 with SMTP id h15mr385029ljf.42.1518925025117; Sat, 17 Feb 2018 19:37:05 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8108:17c0:1500:f666:aee7:edff:2dfc]) by smtp.gmail.com with ESMTPSA id b72sm400115ljf.87.2018.02.17.19.37.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 19:37:04 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Sun, 18 Feb 2018 04:36:35 +0100 Message-Id: <20180218033640.17715-2-tobleminer@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218033640.17715-1-tobleminer@gmail.com> References: <20180218033640.17715-1-tobleminer@gmail.com> Subject: [OpenWrt-Devel] [PATCH 1/6] uclient-fetch: Check for nullpointer returned by open_output_file X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Tobias Schramm --- uclient-fetch.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/uclient-fetch.c b/uclient-fetch.c index 6961d94..46f9b3d 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -122,6 +122,11 @@ static int open_output_file(const char *path, uint64_t resume_offset) } } else { filename = uclient_get_url_filename(path, "index.html"); + if(!filename) { + ret = -ENOMEM; + goto done; + } + output_file = filename; } From patchwork Sun Feb 18 03:36:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 874843 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="T2QkPkWU"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zkXdT54tpz9ryg for ; Sun, 18 Feb 2018 14:37:49 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id A5991B91321; Sun, 18 Feb 2018 04:37:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Sun, 18 Feb 2018 04:37:14 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id D6580B9115B for ; Sun, 18 Feb 2018 04:37:07 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. - helo: .mail-lf0-f65.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 18 Feb 2018 04:37:07 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id t79so8884890lfe.3 for ; Sat, 17 Feb 2018 19:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K/76Jy5voTtgqpkEndWhsIQ9ybbFxQcoiX5ebMTxjas=; b=T2QkPkWU6U7wDXzVthM4+89IM+Je8OjiueMFBrlglAK5zaD8BJWMzlqH77Cill2KO9 0r0LgYgIs7OVy6WZ1uoCMYT/E4IcQVJx/tcI1zjeVe8NjBHgAbk6PWEDZXPw3QvqS5pf elYgDpYuvIzsUxwyeONVbPFu5sOfozmN+0o3t56gDAnn5C5LrfkyYaRHA8jZIwmQFDf3 ZOb8/SRMkJnWJwvMvXfFah60yUdme3ueqAB+Trc4MrCh67u09SXisI2Y93yzzlDLRSsb N8Ur0GoLkaRg33FXxonppcWXvyhanAyAX6GmnRa22AzQg9mTOQ297UXP1A3r6M2IjHh8 P9WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K/76Jy5voTtgqpkEndWhsIQ9ybbFxQcoiX5ebMTxjas=; b=qXTUjAT0bFygmjsesmtmO4oQZESZvys4sMI4/RjCjOutq3/wwpAPfEuDJpmer/t5vG q9riU4WAUjwi8UV2aO/n15/3LP6g9oO4nsntxJzUgSTMFkIxxwj7Jrx2+Hh+uVxpq8Ro exqUcO8EcmAAN/FddL2HXSI1Lu4smosfZ74Iff4ndCKG+EDloVLfZ0pB9p+icdqDTe7J swyTi8wTxVU/c0gimHa4D41/YXpOl9SwQ2C7neRExB48hG6QYJLj7wtsicd0c5UmRGBN 1lXunddDqnGL5+oeKx5iKdGts+t56ll7DZwBOUkXqnbTca1OVWMKMJQbDRzwvAoJ39uP ROwg== X-Gm-Message-State: APf1xPAZ13XBtfz9lqqC88U2luZ+mrOmUAZ0Gu7rrouvS05csrQ38A/Z +eESxDqIChjBMXeDJJXv0E6k4g== X-Google-Smtp-Source: AH8x225qwOk9hrpVSYUyOXxMF+wY92agt9hj3BDBVwtYtY6NeF65a9FdN/q4dK5NaYIKokgg8BvIVw== X-Received: by 10.46.126.16 with SMTP id z16mr1612790ljc.103.1518925026549; Sat, 17 Feb 2018 19:37:06 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8108:17c0:1500:f666:aee7:edff:2dfc]) by smtp.gmail.com with ESMTPSA id b72sm400115ljf.87.2018.02.17.19.37.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 19:37:05 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Sun, 18 Feb 2018 04:36:36 +0100 Message-Id: <20180218033640.17715-3-tobleminer@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218033640.17715-1-tobleminer@gmail.com> References: <20180218033640.17715-1-tobleminer@gmail.com> Subject: [OpenWrt-Devel] [PATCH 2/6] uclient-http: basic auth: Handle memory allocation failure X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Tobias Schramm --- uclient-http.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/uclient-http.c b/uclient-http.c index ef8de98..36e051b 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -299,7 +299,7 @@ static bool uclient_request_supports_body(enum request_type req_type) } } -static void +static int uclient_http_add_auth_basic(struct uclient_http *uh) { struct uclient_url *url = uh->uc.url; @@ -307,11 +307,16 @@ uclient_http_add_auth_basic(struct uclient_http *uh) char *auth_buf; if (auth_len > 512) - return; + return -EINVAL; auth_buf = alloca(base64_len(auth_len) + 1); + if(!auth_buf) + return -ENOMEM; + base64_encode(url->auth, auth_len, auth_buf); ustream_printf(uh->us, "Authorization: Basic %s\r\n", auth_buf); + + return 0; } static char *digest_unquote_sep(char **str) From patchwork Sun Feb 18 03:36:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 874844 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="brwA0vRL"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zkXdn2ZcSz9ryg for ; Sun, 18 Feb 2018 14:38:05 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 06692B91365; Sun, 18 Feb 2018 04:37:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Sun, 18 Feb 2018 04:37:18 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id C6EF3B912A2 for ; Sun, 18 Feb 2018 04:37:08 +0100 (CET) X-policyd-weight: using cached result; rate: -7 Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 18 Feb 2018 04:37:08 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id j193so8900756lfe.0 for ; Sat, 17 Feb 2018 19:37:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JymLS/CgGPXhyUj/fOaLg0eNYc/V3rofQEYtL/ujEUg=; b=brwA0vRL2ZBGzSVgjY5XPk05uhhN5oH+4VNcYZ+XtuWo+7rOORkpDS+WjgsBMfvL9U IJhSqbbHoyH9tW3ZjolUj9CWP9QzLe5kwPSh7GZrtF/Ryb+3rRfP9BkktTWl/oGf99Ce OoHXAZCDcDanzVOwQpQ2990NK5mWezccscDY4FQDjXBbWS+fwGOmZ9CZvN10zfXg3L2q ZgxvRwDoBO0uEYjsfCmFPDFbydBGsAWNUqc9kJa2g4WIjYc5yCUWfV0BhC8NxrJGYWZr 8dg+2885AHbtk66Xge/QxunrwaNfV0nFb10UEgH2zIsxIm/H8KHUmW0+78+ccH8pBocU ev1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JymLS/CgGPXhyUj/fOaLg0eNYc/V3rofQEYtL/ujEUg=; b=DKaSOaKoOotnaGAVfeV/ecirD2LdDyFtQfdRqL9r7+uenKiLzLi+tUHXNUufTy5VBE rXtCXCq+Z4s/f9TYbLjmY0WT30ZP1xGEcV9hA+W9wfP7fby8IRLZci0VGGQDhQasOT0+ l3FwPKZJEoyZc2xyXzl8lzUiv8QZUJWrsfwtXEKv+9GZQHSN1X1HnyNSkUy2eAUz4pdZ mY9U9Mh54xvqqnHJoM6dNEfleARaUfUZG+Tc4xVs4d9BG/NUXNCmbNL3zZL4kyqvCNfU zTJoTGcW7/fkkCrN/ty12/aX2sGgfV62rhrcv6584ZY7R40fFVWJUVi6/rpIZDsdl4p8 BCHA== X-Gm-Message-State: APf1xPBZiKA2sUusy3EAvP8mk/j0I1YFWGQglJNz4GOdSONO3t/eZBRb CCfgkIVbVCb1fkJB+yxIVeYBAA== X-Google-Smtp-Source: AH8x226JPurs0WCFzDhrKmSFRUqBwasyFTMDI3rzTQ/9xK36cEByg2mm8+4g6urGsQM+nSp2CXyumA== X-Received: by 10.46.31.2 with SMTP id f2mr7292646ljf.48.1518925027945; Sat, 17 Feb 2018 19:37:07 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8108:17c0:1500:f666:aee7:edff:2dfc]) by smtp.gmail.com with ESMTPSA id b72sm400115ljf.87.2018.02.17.19.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 19:37:07 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Sun, 18 Feb 2018 04:36:37 +0100 Message-Id: <20180218033640.17715-4-tobleminer@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218033640.17715-1-tobleminer@gmail.com> References: <20180218033640.17715-1-tobleminer@gmail.com> Subject: [OpenWrt-Devel] [PATCH 3/6] uclient-http: auth digest: Handle multiple possible memory allocation failures X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Tobias Schramm --- uclient-http.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/uclient-http.c b/uclient-http.c index 36e051b..2a3cf5d 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -433,9 +433,10 @@ static void add_field(char **buf, int *ofs, int *len, const char *name, const ch *ofs = cur - *buf; } -static void +static int uclient_http_add_auth_digest(struct uclient_http *uh) { + int err = 0; struct uclient_url *url = uh->uc.url; const char *realm = NULL, *opaque = NULL; const char *user, *password; @@ -454,14 +455,21 @@ uclient_http_add_auth_digest(struct uclient_http *uh) }; len = strlen(uh->auth_str) + 1; - if (len > 512) - return; + if (len > 512) { + err = -EINVAL; + goto fail; + } buf = alloca(len); + if(!buf) { + err = -ENOMEM; + goto fail; + } + strcpy(buf, uh->auth_str); /* skip auth type */ - strsep(&buf, " "); + char *buf_orig = strsep(&buf, " "); next = buf; while (*next) { @@ -495,8 +503,10 @@ uclient_http_add_auth_digest(struct uclient_http *uh) *dest = digest_unquote_sep(&next); } - if (!realm || !data.qop || !data.nonce) - return; + if (!realm || !data.qop || !data.nonce) { + err = -EINVAL; + goto fail_buf; + } sprintf(nc_str, "%08x", uh->nc++); get_cnonce(cnonce_str); @@ -510,10 +520,17 @@ uclient_http_add_auth_digest(struct uclient_http *uh) char *user_buf; len = password - url->auth; - if (len > 256) - return; + if (len > 256) { + err = -EINVAL; + goto fail_buf; + } user_buf = alloca(len + 1); + if(!user_buf) { + err = -ENOMEM; + goto fail_buf; + } + strncpy(user_buf, url->auth, len); user_buf[len] = 0; user = user_buf; @@ -540,7 +557,13 @@ uclient_http_add_auth_digest(struct uclient_http *uh) add_field(&buf, &ofs, &len, "opaque", opaque); ustream_printf(uh->us, "Authorization: Digest nc=%s, qop=%s%s\r\n", data.nc, data.qop, buf); - free(buf); + + return 0; + +fail_buf: + free(buf_orig); +fail: + return err; } static void From patchwork Sun Feb 18 03:36:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 874845 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Vr00109B"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zkXf30Z40z9ryg for ; Sun, 18 Feb 2018 14:38:18 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id BF88BB91386; Sun, 18 Feb 2018 04:37:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Sun, 18 Feb 2018 04:37:24 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4DE66B912A5 for ; Sun, 18 Feb 2018 04:37:10 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. - helo: .mail-lf0-f66.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 Received: from mail-lf0-f66.google.com (mail-lf0-f66.google.com [209.85.215.66]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 18 Feb 2018 04:37:10 +0100 (CET) Received: by mail-lf0-f66.google.com with SMTP id 37so8863918lfs.7 for ; Sat, 17 Feb 2018 19:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nBAZuLYlHbmtazovP39ZX98+cH0t90aFxC8IFOQCIII=; b=Vr00109B5sPups7/igqzz7Xf/V7SyanQs/coXqAnS2ORxp0cpnso//847YzP1jy7SY hGuS48aQ9bz0ko4r+fCt5HomQBnVu7n6h2DA2V6qSqxCVSD3LlO6mhpizEyRFcUxRjX6 /eIqpKEWUwj+q55AHoBTulBf5iFVuAQpOqinHl0FmcfV04KIbnR0sYZp2JzjLuZQOjMY HNthtckh8LdgVNkPnCgt2X4rw8QSqGsib9xsJQi2vrt9M4+9vVgIgJyhlhNuStpJd+Y2 OBtVvTI+KzAVgPgsNQJe9m6FQgARou+bpfIBRA0URMVYfl4JTB+RAZMBwVCKeYdZDN0X wSmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nBAZuLYlHbmtazovP39ZX98+cH0t90aFxC8IFOQCIII=; b=pZNBmjixiVjKA71a87iCoJnB9nxCxVy7NBkM01jUPuKCDTpAS45ZHXBuUUk+7T4iVS kZOZzFTZoAOuPM24J5DrQIvM2KV5o4pfaoHVJ6TVfgFNMsle5SATvSLCHy+h0y1RJRJz MQ8R56k1uE2Q40NkhsCRItYh5OkfY/r4mlKGgaXowMNRcc0uQIpEoKUIW4ivbEnBUwh7 D201BfI/DE7hN80aG1KggE4AEqgcCeTiZxv4nML7xVEIWInJXtZ145EGtnxjJCTfA3Ft MLNw31nWEaWoV1taW8LHCr0ZKyI0NAEqQElygjtqnkpmJVWeSMCzucFCiKvv5aD9yYQi LXQQ== X-Gm-Message-State: APf1xPALgGWXS7AOAuyEouv75HyjvkjnE7ySI8Qxqmf7lnmdEreOUtyf 2AgE60hwl0XHnIcmv8pkd043vg== X-Google-Smtp-Source: AH8x226JNdq2tPusddsTHBLu+mJNCTN1n6sg4vYJkQmxAF5MTMXhTyKsGz5fE2JlH2is9gvlwDWuGw== X-Received: by 10.46.23.219 with SMTP id 88mr7137850ljx.49.1518925029274; Sat, 17 Feb 2018 19:37:09 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8108:17c0:1500:f666:aee7:edff:2dfc]) by smtp.gmail.com with ESMTPSA id b72sm400115ljf.87.2018.02.17.19.37.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 19:37:08 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Sun, 18 Feb 2018 04:36:38 +0100 Message-Id: <20180218033640.17715-5-tobleminer@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218033640.17715-1-tobleminer@gmail.com> References: <20180218033640.17715-1-tobleminer@gmail.com> Subject: [OpenWrt-Devel] [PATCH 4/6] uclient-http: Handle memory allocation failure X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Tobias Schramm --- uclient-http.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uclient-http.c b/uclient-http.c index 2a3cf5d..24f091e 100644 --- a/uclient-http.c +++ b/uclient-http.c @@ -944,6 +944,9 @@ static struct uclient *uclient_http_alloc(void) struct uclient_http *uh; uh = calloc_a(sizeof(*uh)); + if(!uh) + return NULL; + uh->disconnect_t.cb = uclient_http_disconnect_cb; blob_buf_init(&uh->headers, 0); From patchwork Sun Feb 18 03:36:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 874846 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="K8EGdEss"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zkXfK3kG7z9ryn for ; Sun, 18 Feb 2018 14:38:33 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 1D5EAB9138B; Sun, 18 Feb 2018 04:37:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Sun, 18 Feb 2018 04:37:28 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 7CA33B912C1 for ; Sun, 18 Feb 2018 04:37:11 +0100 (CET) X-policyd-weight: using cached result; rate: -7 Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 18 Feb 2018 04:37:11 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id j193so8900804lfe.0 for ; Sat, 17 Feb 2018 19:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dX38X7EX0zR7xwxOAe3ItLO6a+3GqtP46RnqwsO3C+8=; b=K8EGdEssh+vQV/zSzh+N400dI+G/MfBsPurzfU/CxCsJ5DN5eKBJwHKan6VWnfzICX MYREBY748xyzR4jLLsVUIW4Pv0C+YEjt5VIv/njP+ghUSDQ1Kr1wViheq5B1uTXVyq1T qNXJuHtxuFglG9mrYtXyAccSB8zduWfzzPYGTPmTnTPKuIxOJIJYUR4TrLPwINzURLjT 4qpUvgslUcwt0eedko1nNNZ/rpIcCKeL0jX30XZGnG+6RxCr2BjYRdpRamyMXLdzEJJ8 5ptgQwIMUwb8m7Gr3gMa87mL8eRuhlJz8D9DvQD6ZqsgFfG8dwS4VSlDdOT7mfPFWbbX bmcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dX38X7EX0zR7xwxOAe3ItLO6a+3GqtP46RnqwsO3C+8=; b=BJxpNx5uqTSmkrxjn/tASTRAUABXAjTW7jcSwq+sMwzRZMSpFbACvvN47AJ3m6fwWv nzoMdjpDAlZbs8mZ26dYN0mgvddLRtslLtKh8XekhGYuCDzYAap+q83V/t+tspWlS9OB DWifQJy/OwzSvwIk2qI+CdojprVNm1MAM32bDZPU/r7agehb1rtjqp4t1Q8GAWtu0Abz ypTXWhW3fzSlpUt6IZun4Zi9Q7yV5HKH4ouPAfcj6b5fG/p0JqyJ1nJLFnqwBDDdQIk4 Jny4LAUUlDjz+cZT80jSNTyksLQUlvl09EImvcdRQgAQtCdGRWl0QDoedXLSH6ZisZlE 8e+g== X-Gm-Message-State: APf1xPATV1GvWx0HvGlBZteg6PV+sCjzD5O0TbKMCJCRNHYMhUtb0CiQ EKXTtgv+z+jkRfXkCkMFz1fH1A== X-Google-Smtp-Source: AH8x227twI0HKZkVXyzyaswZ2AAL1aZtgKnxneP7DxsbwOaenv0ML25yaFAn/3uGJIQCpqW7OXViBA== X-Received: by 10.46.34.129 with SMTP id i123mr5429153lji.108.1518925030624; Sat, 17 Feb 2018 19:37:10 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8108:17c0:1500:f666:aee7:edff:2dfc]) by smtp.gmail.com with ESMTPSA id b72sm400115ljf.87.2018.02.17.19.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 19:37:10 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Sun, 18 Feb 2018 04:36:39 +0100 Message-Id: <20180218033640.17715-6-tobleminer@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218033640.17715-1-tobleminer@gmail.com> References: <20180218033640.17715-1-tobleminer@gmail.com> Subject: [OpenWrt-Devel] [PATCH 5/6] uclient-utils: Handle memory allocation failure for url file name X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Tobias Schramm --- uclient-utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/uclient-utils.c b/uclient-utils.c index a375eea..ee0f8e8 100644 --- a/uclient-utils.c +++ b/uclient-utils.c @@ -177,8 +177,12 @@ char *uclient_get_url_filename(const char *url, const char *default_name) str++; len -= str - url; - if (len > 0) - return strncpy(calloc(1, len + 1), str, len); + if (len > 0) { + char *fname = calloc(1, len + 1); + if(!fname) + return NULL; + return strncpy(fname, str, len); + } return strdup(default_name); } From patchwork Sun Feb 18 03:36:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Schramm X-Patchwork-Id: 874847 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (helo) smtp.helo=arrakis.dune.hu (client-ip=78.24.191.176; helo=arrakis.dune.hu; envelope-from=openwrt-devel-bounces@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HcI4+xQH"; dkim-atps=neutral Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zkXfb0JYTz9ryg for ; Sun, 18 Feb 2018 14:38:46 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 59D05B913DD; Sun, 18 Feb 2018 04:37:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Sun, 18 Feb 2018 04:37:31 +0100 (CET) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id C278AB912F0 for ; Sun, 18 Feb 2018 04:37:12 +0100 (CET) X-policyd-weight: using cached result; rate: -7 Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 18 Feb 2018 04:37:12 +0100 (CET) Received: by mail-lf0-f65.google.com with SMTP id q69so8852795lfi.10 for ; Sat, 17 Feb 2018 19:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XKue/1EAOtbmKyfHQmzbYt74u45OhdBW+AeYDST+ssc=; b=HcI4+xQH9T5KQMmie5VPnR3sTIIx9VIfdMZ8sKT9mcMJEX7ndgJwDWfx+tLXKRf7OQ qA/Yx2bSvYa7kpCioUL1Zj2OBWWyDtvwAKlk1u/PqxJ8Npjh7V0+3WHGt+f0F5YdrXpL JQuPUpo4RxNmgYXlb/rKCoh9jz1AK+i6AjlmybIb77wDoAwiF0enuygXMOrAAPg1DTC1 QYC4Xm1WbOyEtD2q4G3n4oUqDDLAvNdtOARqTozX/uxNiRLALyKqzmuR3iORZp4i4Pxj zRU5jx9AziHTfwY933gpgrSfEb3OCzQD5uyEFWyf3+CSr8DEfA+25jMYehSVXz8/dXab +S4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XKue/1EAOtbmKyfHQmzbYt74u45OhdBW+AeYDST+ssc=; b=QUy0CMdxYlUImB63UvjmBVGReTgBfaHIl4Y0bErhQRc35sZOvsrdenZbduGMNbpdHc gj0y3r9IR3BJncnowRhQCbzH/OpLq93LDua9uhkgCJHWrHtOCEgmgZx6Vs+NdULVsuI1 JnhAksmtZTp7lwOw+ShYGrwCbXq8c2czswuSCsg3wX9CkOLBq1EkweS4pPfRjTbtwNyd vLLAs9xsn9aENjDtYBvprFI3c3xDg+wxX7caZ+weFrKPwVz3V0VKMzKII2e9O9E+lTrf QdOh7k/IKtrE05BFIKShjNcOe+U6lBrdlrwiAxDrYoPo7XoybZSbp1oq1AiFSNglZaIk C4xQ== X-Gm-Message-State: APf1xPCXEhKTGuuqJxj01WXwsaw7PaeAsBygnokS2WK6wCk9fHJ7tYGl tNIes9zn3dH6NsyqAmZu0m1TGA== X-Google-Smtp-Source: AH8x225RUGAye1NSEoLJayFhFfIjS6fdeHT0jIR36F0BnWpCCuflTwxYsz2FBv6srTlz9zFHGTI3/w== X-Received: by 10.25.29.81 with SMTP id d78mr393124lfd.18.1518925032022; Sat, 17 Feb 2018 19:37:12 -0800 (PST) Received: from sunsetshimmer.lan ([2a02:8108:17c0:1500:f666:aee7:edff:2dfc]) by smtp.gmail.com with ESMTPSA id b72sm400115ljf.87.2018.02.17.19.37.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Feb 2018 19:37:11 -0800 (PST) From: Tobias Schramm To: openwrt-devel@lists.openwrt.org Date: Sun, 18 Feb 2018 04:36:40 +0100 Message-Id: <20180218033640.17715-7-tobleminer@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180218033640.17715-1-tobleminer@gmail.com> References: <20180218033640.17715-1-tobleminer@gmail.com> Subject: [OpenWrt-Devel] [PATCH 6/6] uclient: Handle memory allocation failure for url X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Tobias Schramm --- uclient.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uclient.c b/uclient.c index 8862b55..dfbe26c 100644 --- a/uclient.c +++ b/uclient.c @@ -59,6 +59,9 @@ __uclient_get_url(const struct uclient_backend *backend, &uri_buf, strlen(location) + 1, &auth_buf, auth_str ? strlen(auth_str) + 1 : 0); + if(!url) + return NULL; + url->backend = backend; url->location = strcpy(uri_buf, location); if (host)