Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp12013pxk; Wed, 16 Sep 2020 15:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQZD+3LnVvc3zAVk/SBaaCMxGVuDXN1tKF6J4kuZbetaIJR0pIp4JGZ/Um7Y523jN53ayy X-Received: by 2002:a50:bb26:: with SMTP id y35mr31177014ede.234.1600295743060; Wed, 16 Sep 2020 15:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600295743; cv=none; d=google.com; s=arc-20160816; b=nM4KL4c18VC2UAZYDqbFXXUPMekgzwppDMCJ1cp6naXnxdg0dha6B4X/cAsE4ffqwt WA0qbXx/UkhjtLqpT+SwzzE6jK6d9VgvAiuIbBxe2H6MO3Z+LhHIvKYeL2tvkGn3aGHl HlszHbc7+dj20DpQ66Z0+OryOnRFyjrL0+sU0JNqPEqgO1l/DVmyOrSPAWWhTqWEpG3a yyhFaxP5LP9Twlxesr6zTNUSfd/kiuPdHV3l19/GZM4lxEZ6KWMqwjknkUUOXDSuiO8o i/Qy3G5DZlIvqc3tCjyInmvkMFqSvQ5CXgk8jmnwBxZl8ZJ27+1p0tHtzl/dtpXII7JK CLOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=vOOj7JrORSQZoEmLdmbV9btt2nd8uMdE47oZ3fG6JksM8eJmulR7e5WZVvffM32NU5 +B7G06kpDNbXOuFd+x2Ec9vlLiDnfH5gZBRCr+mwt5oi4fh1B684JkT/vyTVDw4Psq/U ZRupcjmrTu1Fn7s5Sop7KrRW1zTqTsmmC+Ce8myR6IIbAfvx2i0JJsEor/X55FZIOFvh 8SmUR2cAiNr83u6SyY3r7PNxnTInjsW6bkXNOSxcKrF/dNcRIBIb3uDQWGNilnavC8m+ K5d1GEYcxL6do+s5fcfw5+NQj7meM1vRbTthFVq1xk6kaME0kf1VZGq8+Zd2vkLsVLvI DnCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XqxtSK1r; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si12735885ejj.683.2020.09.16.15.35.17; Wed, 16 Sep 2020 15:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XqxtSK1r; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbgIPWfL (ORCPT + 99 others); Wed, 16 Sep 2020 18:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgIPWfK (ORCPT ); Wed, 16 Sep 2020 18:35:10 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9BBBC06174A for ; Wed, 16 Sep 2020 15:35:05 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id w7so4854413pfi.4 for ; Wed, 16 Sep 2020 15:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=XqxtSK1rf9GqTXNLezWlbuk12soFDktvIyV8otXHyvVqzOmtklfCcTA0lcncgqylZx kx9lGP3OtWm9TLVlNKgXTSg7qdkwebNzUKqb2Fu4pnthQTCOY7TBf+qQwrP33xNYuHV/ Sf1q19C+RtZo4LkvBVkixXws22lUEizKi7pjA= 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:mime-version :content-transfer-encoding; bh=z4BsBm4/JaybyWDiNEa/bs5RXulRrirwodkdVtO+qdI=; b=IGYxOyIHVWZtOP6icu2YLvdUJdogQR0DpbUI/V/kxi6DGjy6Vcdlp5/tutxfpI1F8W WOO+taxR+8H3oJL23z4ggZy5mbrpU0P103fguzTP+WS5o84YNjA/fBuBHMD7TAt6tYv3 JZHxgGYwx/TfckUxPblc4tjxS2mirWqeay4eLiu7XZXopNpLR+deOB4XMYSDhievzS4f SOQbp5DRFx5pblibXV8IapZxjWA4tF++rw25bh19t0viKyMz8nrivcoGg2223GyZ6B0Z dHGtA1H/vZL7MeKvSKPvQ+F+enBv4sgurRpw2vhmQYttequXTV8FNnYoja2DWgz/hJy1 dSUw== X-Gm-Message-State: AOAM532ch1TkBkX7iCBGlTFRY41iDKG1qeJvdu2czy7Df7/0KO+3aHHq OR8fRbneZrE9Uu7c211rARq+xx9wUTtC0Q== X-Received: by 2002:a62:1850:0:b029:142:2501:35e8 with SMTP id 77-20020a6218500000b0290142250135e8mr7991711pfy.72.1600295704821; Wed, 16 Sep 2020 15:35:04 -0700 (PDT) Received: from sonnysasaka-chrome.mtv.corp.google.com ([2620:15c:202:201:4a0f:cfff:fe66:e60c]) by smtp.gmail.com with ESMTPSA id e27sm17945805pfj.62.2020.09.16.15.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 15:35:03 -0700 (PDT) From: Sonny Sasaka To: linux-bluetooth@vger.kernel.org Cc: Miao-chen Chou , Yoni Shavit , Alain Michaud Subject: [PATCH BlueZ v2] sixaxis: Fix crash caused by return of udev_device_get_property_value Date: Wed, 16 Sep 2020 15:34:53 -0700 Message-Id: <20200916223453.22537-1-sonnysasaka@chromium.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Miao-chen Chou This adds a NULL check before calling sscanf(). Reviewed-by: Yoni Shavit Reviewed-by: Alain Michaud --- plugins/sixaxis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 939fed759..996f85dd6 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -411,7 +411,7 @@ get_pairing_type_for_device(struct udev_device *udevice, uint16_t *bus, hid_id = udev_device_get_property_value(hid_parent, "HID_ID"); - if (sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) + if (!hid_id || sscanf(hid_id, "%hx:%hx:%hx", bus, &vid, &pid) != 3) return NULL; cp = get_pairing(vid, pid); -- 2.26.2