Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5556589pxb; Mon, 14 Feb 2022 01:49:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxd+1Ftv9EkZoG9yMowCylEGXktMACTbOHYj72bGxftepbRBW1rk82Sa2sR+fEIahnqadD6 X-Received: by 2002:a17:902:db11:: with SMTP id m17mr9957565plx.103.1644832186415; Mon, 14 Feb 2022 01:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644832186; cv=none; d=google.com; s=arc-20160816; b=JIrseFIESyzrVtFmYigtoZI+TiZDPKFOyavOjtXJ/ANgLn/NG7trOjJx3QehWCQ1S5 ge7xCGUn1+haqmyOO4aIx+UcHrlcM/642d+fFyEyb4AzDvhXdxUsIi/BshTkiMH5yj5I gDPSbs4uA+xMXz2F+pzguqpYfDyZVXOkzZPnE4PfdBSzvC1wjOTDiElGMMsIe9Jm2sGl OqATBI9Em6byn14dSrN6Lw6arkdwdV3sT47URuNRFjwZyk4jZPLMr6bNmvB28zns2hfr 8P7HnxrBhi0n8Oq5TlGtd7+VDTLYXmPoc69D9a/erH1/eIBEKs02oB793c+O+kHYibGK zqNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=qOJUau3R9DNwghj7AGgRGxzrrSvkfkutzqGQ8LXl1n4=; b=lcAjqjxMsDyWK2TPQBwF5e1bHM66PwxH9gIBgH401elU9+ZS9zFz+D1li0QOX19++C AgTLwZMfeD0dUZ2oUmEUbhzBnqzavEtT9tbem2RTWzr2n766BJVWO7ksE+lbUDTjcdrO tBuGo4dff/L9BKwzw05GnCjvJ1uvPiEyf/Xv0bKliAdMmDZTce1TPYPtqEMs/VgP9ieJ hz52vcnvAtWaxfh6UuiBLeihsTEO0UbkUWxp5T95mvdpEdINOsKah12+sl4XN1oNvPP3 WsF6YzFhYCLIyirDZ0bjrtcdoBtzOPWg12/cY7gnuJX1EAthiopFS2lqrP/aeGpv4y21 MqLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="WiqoSzc/"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa3si10168264pjb.177.2022.02.14.01.49.30; Mon, 14 Feb 2022 01:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="WiqoSzc/"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbiBNJN6 (ORCPT + 99 others); Mon, 14 Feb 2022 04:13:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbiBNJN6 (ORCPT ); Mon, 14 Feb 2022 04:13:58 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B86860068 for ; Mon, 14 Feb 2022 01:13:51 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id m10-20020a25800a000000b0061daa5b7151so32551504ybk.10 for ; Mon, 14 Feb 2022 01:13:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=qOJUau3R9DNwghj7AGgRGxzrrSvkfkutzqGQ8LXl1n4=; b=WiqoSzc/MoHiP8/Y2wi9GAOycBK62nhA2OMYTU9WGBK1hT3n9E0VLIStOJKRL3jUFq k3JCmQH83bsW1xK3ocehxZd8vEZgkorBAgc19FRMvT0Mbo7zvs3bITzF3wEXLCKdytOa HOM0IyGzVu9ONxgGFuAUZ/EIbzjep+rUkc9h7oh5h+Vsg62jI+nwVypS9O4EtjFDh/C9 S5SmLvvwi6ybjIj0SxEGLribnBtD/m32Jh8eiOSoWLQnH7/q6xBzu+Ggba3S0rLqW+cX gHRyKQt3s8N3PvV+8o5qlG2Gw9jZcExB+UjL/ZWbfv1SOA0LT9l/judDs4i/f0KOiIbe paww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=qOJUau3R9DNwghj7AGgRGxzrrSvkfkutzqGQ8LXl1n4=; b=itABWM5DzYzn4xTFSHjuEQackWWnCTamPA8/eAwsqVEeFN8sK46UJyzOgAxLAqdlAL lK+wRxtDy8I6Ns8fC6Roeq7B4n4iw2sixagm9nM27K1oXvwsCDke46eus/NkSkfHRdlM hOPE8nNTA6lv0/JXJxLxeeemZuX0n5hCIldEc/FafCrV3mlu7GQnpwX0khwmhtqKAKqA 8pzU0UjtDIW7Qewov7DK7v38GOuyMu+r1bzIsnRhYj6DkarqX2yZcN49Qe3fPWYfFEmp fzSZEITg3diUbDjXy8zvaWSSEMi7k6z4tDPIXstqcHq9klEI3PbskPWqfzYa8LmoWgrt Uaeg== X-Gm-Message-State: AOAM532j6Zy9uT31cZDdONj0SpQg07MXh7NZ0U5aiNwhifJaRjMAUFjs 5PRWHpjXB5HqiPkTf9Ms+toL8ZmQgq5N+QjYeRlZ25xzf9+wL2DCgDsBGHvDC45eukwvtnNvpcP wOBlLvV1Rf8pDYH4fSm1GDtZXJTZAdw1LwYuUn+gDh9hWZ8KntWW5fdTudlXmHkCFZ4SIPyHBPr l4pZNLoIOmBxI= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:b204:5f3:5b41:e9f]) (user=howardchung job=sendgmr) by 2002:a25:d512:: with SMTP id r18mr11563551ybe.87.1644830030294; Mon, 14 Feb 2022 01:13:50 -0800 (PST) Date: Mon, 14 Feb 2022 17:13:43 +0800 Message-Id: <20220214171329.Bluez.v1.1.I8c72b5af2506378bba6da369228ae50483231e35@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [Bluez PATCH v1] lib: fix hci_strtolm crash From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Cc: Yun-Hao Chung , Archie Pusaka Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Yun-Hao Chung |str| can be NULL in the case of reading lm value. Calling strcasestr could lead to a crash. Reviewed-by: Archie Pusaka --- Verified by running "hciconfig hci0 lm" on hatch lib/hci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hci.c b/lib/hci.c index 5141f20ac..5228c2ad2 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -323,7 +323,7 @@ int hci_strtolm(char *str, unsigned int *val) int ret = hci_str2bit(link_mode_map, str, val); /* Deprecated name. Kept for compatibility. */ - if (strcasestr(str, "MASTER")) { + if (!!str && strcasestr(str, "MASTER")) { ret = 1; *val |= HCI_LM_MASTER; } -- 2.35.1.265.g69c8d7142f-goog