Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1357326lqb; Thu, 30 May 2024 08:01:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTAIQE6Z49WgPGgMXtJqTM6i/stX4or3GdLTMX0IXdv7ZCmX4XrSmNVDi6YMMIpKBOhG3CyFg+0lAl3D+25YmuBLA3Qwua/yFiZsbmjQ== X-Google-Smtp-Source: AGHT+IGUgfm/o+YPSO/HzLl+MCvbWWWPK0D1CHX6v6l09YVV4Yrnbmp7nHVQ9s4i4BSJq6HOdsm2 X-Received: by 2002:a05:620a:294d:b0:794:9adb:8de3 with SMTP id af79cd13be357-794e9e1823amr290909285a.48.1717081291247; Thu, 30 May 2024 08:01:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717081291; cv=pass; d=google.com; s=arc-20160816; b=odL1qx52spWZJoLkpzwjcQ8Nq1wRaoisn1c4aTOuu2N0qnDwBYqArLCNImtzOh9hO7 LNYjBKgzTnhw0WFmZedD8Q0iMg3rw51G122JUvTq0lM4AjCSGvvWWGrN5jIHA3//1k4v JLCvQ00a81uTb2FR+VE1V8SAbwcEJst+tw7+msi76VJiIx2g+L9GgN8w2UL+1U9qJRbj cxIlt0eJABd4Uwj0Sc7bYhCgJrvF1KxfixL1URkp7MPYOEdsib+EEUS1EMHCNucOvaoE 7CWxYwvjqkomitNcUFg3vnMX6KAUlQ+y9RuRnmxRChemya/pUqIWbo3MeltS3ebgWN35 kynA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Ss5/qYdi0yu44aUvVHp9lGBnCWKcgpzuqUDBOK3ZHyc=; fh=uo5u2TQK/HQlhydMwGLjBAnuDwaLxndJ/cgWTjIagS8=; b=sESgKIUp4Oo6QjfTEROsYVbN7B7ulUNlu1JYFXOp1gW99/PBH2JYO/ixQXKSVWoEo9 Gut5ytiFbuO6sap+zT+mrSR1dQ5SQa9tp9EMyn5yrcKOn7D/3CW/gejb7v73Vz1jbWhi 3JABr9jS+qPCzZK0zgTAVHkcROFrn3CiIFF4qOJYpwWl04nQyMzl5Vi8kQYrY7UxhhUw LHpCcZBpMrc2UYgLrxtULPXZDp3SNQkMyq0I4tZnhYUIhnQ3br7ROwXbCdUPTUXGHNqC PAsKie+n9xHdbkK45NDf6WQY0/jDC3IQLhteaJDjUQ+r39zmGfOyCWUj+E9Tuh9XQPS+ 3ssQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-5043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5043-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794abd5ebd6si74088685a.712.2024.05.30.08.01.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 08:01:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-5043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-5043-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5043-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CC85C1C23A7C for ; Thu, 30 May 2024 15:01:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A489517FAAF; Thu, 30 May 2024 15:01:04 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54D7F17C214 for ; Thu, 30 May 2024 15:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081264; cv=none; b=P6M6Ogfc2+uz6CPjWKVF3UHxqxU6RfZzQ7fdbB6MwFxs0XU81FwKv2x2ru+IcaxdyPi1OQDw0SEmFu58CB/uGJ4pUuzUOoqgtsO+LffOkfANhiH0vQEBZBAmDBD3iPuz/NC7QS/JM7bpcxHq2jl4dSksQ7p8Lm44+ya2r9KqG7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717081264; c=relaxed/simple; bh=nRdVYVVSmZ2ZAu8GRAxcCR1c4rYFBz0G2V4WoL8zsrc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ep0Fag/wnuF9pisSD1WrVa06mTembMhUNUToywdXvYDV0hERSQ2Davrd7arm5ve39BZ7zjzMLRbFTk2mU8TJ0Ep3k+Xtn7j/xqqEtFzpMYUxkwegmZxBHMlRudcFu0UijWjN4xQtehBTRwmH34A4Z1QnltUbkL9xUZpmasiqEGY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id A81A520011; Thu, 30 May 2024 15:00:59 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ 7/9] obexd: Fix buffer overrun Date: Thu, 30 May 2024 16:58:01 +0200 Message-ID: <20240530150057.444585-8-hadess@hadess.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240530150057.444585-1-hadess@hadess.net> References: <20240530150057.444585-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: hadess@hadess.net Don't access path at byte 2 when it might only contain a single byte. Error: OVERRUN (CWE-119): [#def27] [important] bluez-5.76/obexd/client/session.c:1135:2: alias: Assigning: "first" = """". "first" now points to byte 0 of """" (which consists of 1 bytes). bluez-5.76/obexd/client/session.c:1142:2: overrun-buffer-val: Overrunning buffer pointed to by "first" of 1 bytes by passing it to a function which accesses it at byte offset 2. 1140| req->index++; 1141| 1142|-> p->req_id = g_obex_setpath(p->session->obex, first, setpath_cb, p, err); 1143| if (*err != NULL) 1144| return (*err)->code; --- gobex/gobex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gobex/gobex.c b/gobex/gobex.c index fdeb11c65130..40d6b8129b00 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -1611,7 +1611,7 @@ guint g_obex_setpath(GObex *obex, const char *path, GObexResponseFunc func, memset(&data, 0, sizeof(data)); - if (path != NULL && strncmp("..", path, 2) == 0) { + if (path != NULL && strlen(path) >= 2 && strncmp("..", path, 2) == 0) { data.flags = 0x03; folder = (path[2] == '/') ? &path[3] : NULL; } else { -- 2.45.1