Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1873770ybk; Mon, 11 May 2020 06:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyq/R55Sn6T7rl7+NpFVPUOQ72lcmnWrwrr0TfzPHuA0LVfae7n2aUu2hyAua9aJL/saZWo X-Received: by 2002:a05:6402:946:: with SMTP id h6mr4834032edz.245.1589203796876; Mon, 11 May 2020 06:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589203796; cv=none; d=google.com; s=arc-20160816; b=Y7lp3TZlTgcXx91Rxb9h4t7GHuDq6ph7UWHmjppxxSq7pxVgN7wsZDZJjikVxJlxRv LhvaM6iq5RnrxrecN/3740nK8wlwGTCK1j4mkUvKGcY8GQI25oHls2QJuSoUG46dpyjV QFC1RSmreNm5QBzHZAUffXm10M1C2qOfIhnGsut2Yp/TAKTMA4BIILZ5kodLAIhneoAJ fOKEsKMjrhYJsXMZflNgZvyIEsKOxsh8g7HRBuetSFjiHSQz8rhVwcv3f7bKOPchWGUd cUu5xe7Rg4yaDL+iHXuJmLBYgDNPmwxc4R1UxZu12Fj1DMV4Trd2OUakPoYRF730VoS7 WAjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature; bh=F3PrhpusTFa2IxB1+2ym5YG5U8+6riyJNWdQH7sYGt0=; b=iOom/Z+UDpfl7ChxuiTpho1bl33Y3V9DJ9b66NIHjknn/RO8iF6uPnLLTY3NAZjWWW HWZ6aTSkIphGhvu4ptrX9lgupx/1JLJIlwYkcZ4nMpqaVKQof9h/qi8aQeW+zyl2gbqG fzzterv2sh/zzkgl/lPt9dm9tQEb5DFwwVM4vxNhrtGSPi/NggLpeJQmt/Z1ukH33jg9 swFe0IOvWVnRRPiH3o1SOp3Se1T++LjIBRWB11LWI3PINazq7OaDtIHmlwJGpO5shJvU wGt0eVCIx0UZzuizi+WUTSScR4ntTn35mND6CmszK79+YFPZEs5zoHosxWIwBIODJvRv z03w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codecoup-pl.20150623.gappssmtp.com header.s=20150623 header.b=xj7FHtp9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si5886086ejw.454.2020.05.11.06.29.16; Mon, 11 May 2020 06:29:56 -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=@codecoup-pl.20150623.gappssmtp.com header.s=20150623 header.b=xj7FHtp9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726115AbgEKN3L (ORCPT + 99 others); Mon, 11 May 2020 09:29:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726013AbgEKN3L (ORCPT ); Mon, 11 May 2020 09:29:11 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12585C061A0C for ; Mon, 11 May 2020 06:29:10 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id a4so7495697lfh.12 for ; Mon, 11 May 2020 06:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codecoup-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:in-reply-to :references:mime-version:content-transfer-encoding; bh=F3PrhpusTFa2IxB1+2ym5YG5U8+6riyJNWdQH7sYGt0=; b=xj7FHtp99SXyYxP7cQQqa5yPaVuESMhXfNHNr5n34PQjJJTP57f6zwirB2uvlnp6Az liTbc/j5DXYDB7ziju9FxNLDUaeHU5xzZ89xcl0uHYMnycwduzBM9WVteek0sUp+O+3C xDCui13T6TCSYyi76XsG2kBB2jh3ngCle7pA1fYa3V6vDGe6n7FdYJnsvSsHGVGh5Qws hEkrZfL+fmPafCX2WD4Ib6l46m8OtpTZApVZscZ2znawSs8WhY/Rru8Qqy79jc+dpqEZ ebiACDCRu5H74CZ0Dy1b97xwrOhq0mgzPgP0bQoGKT6uzJm45DNt8zPAYWeBTnc9UuGD XYGw== 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:organization :in-reply-to:references:mime-version:content-transfer-encoding; bh=F3PrhpusTFa2IxB1+2ym5YG5U8+6riyJNWdQH7sYGt0=; b=SxsO1pQkop8sQiFxk5HO2hxIJjqJ8c0Yn5OgbgHXvxxpfBE27tmuwDljKbJcjCB9dy Rnk6hww7OnYdOQNzP07WUdGX+75sjQtzIr07vIR7cI/dRb/L7TUTlLa+y44A8Y66XfgJ ig04jdGoGPY2iOFmnjnU9JPAJdKWDQvDNFKqZduNuKaSO7ZQrqOp3NQFXX1Sdz3mf8jz gO/6cfxtKxNhgyVN0xagZ9sGFEsGqrO8TYmC0h96pIb7ApjOe6m0N++aPVkKkpIsYuum wES3cmp+M2ux5Nr8xbCwRjPfiUYdyxhWOw/ViTfBF3SUOidmrVRrOYO8AlLBhjPyQo5f IfpQ== X-Gm-Message-State: AOAM532XTRdeaB6brsNyS/OH94giI5F3Jq9YGpEHyH2NyUfkwOuLA2NP 28vfUdnoo7XI1w9YOi+l1dYicIvL9v4= X-Received: by 2002:ac2:563b:: with SMTP id b27mr11227403lff.149.1589203748161; Mon, 11 May 2020 06:29:08 -0700 (PDT) Received: from ix.localnet ([95.143.243.62]) by smtp.gmail.com with ESMTPSA id s4sm10923583lfs.30.2020.05.11.06.29.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 06:29:06 -0700 (PDT) From: Szymon Janc To: linux-bluetooth@vger.kernel.org, Mariusz Skamra Cc: Mariusz Skamra Subject: Re: [PATCH BlueZ] client: Update write callbacks with invalid offset error handlers Date: Mon, 11 May 2020 15:29:04 +0200 Message-ID: <2528440.mvXUDI8C0e@ix> Organization: CODECOUP In-Reply-To: <20200505082901.258762-1-mariusz.skamra@codecoup.pl> References: <20200505082901.258762-1-mariusz.skamra@codecoup.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Mariusz, On Tuesday, 5 May 2020 10:29:01 CEST Mariusz Skamra wrote: > This patch adds invalid offset handlers to write callbacks of attributes. > --- > client/gatt.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/client/gatt.c b/client/gatt.c > index 416eda953..5713f8343 100644 > --- a/client/gatt.c > +++ b/client/gatt.c > @@ -2141,6 +2141,12 @@ static void authorize_write_response(const char > *input, void *user_data) goto error; > } > > + if (aad->offset > chrc->value_len) { > + err = "org.bluez.Error.InvalidOffset"; > + > + goto error; > + } > + > /* Authorization check of prepare writes */ > if (prep_authorize) { > reply = g_dbus_create_reply(pending_message, DBUS_TYPE_INVALID); > @@ -2272,6 +2278,11 @@ static DBusMessage *chrc_write_value(DBusConnection > *conn, DBusMessage *msg, return NULL; > } > > + if (offset > chrc->value_len) > + return g_dbus_create_error(msg, > + "org.bluez.Error.InvalidOffset", NULL); > + > + > /* Authorization check of prepare writes */ > if (prep_authorize) > return g_dbus_create_reply(msg, DBUS_TYPE_INVALID); > @@ -2683,6 +2694,10 @@ static DBusMessage *desc_write_value(DBusConnection > *conn, DBusMessage *msg, return g_dbus_create_error(msg, > "org.bluez.Error.InvalidArguments", NULL); > > + if (offset > desc->value_len) > + return g_dbus_create_error(msg, > + "org.bluez.Error.InvalidOffset", NULL); > + > if (write_value(&desc->value_len, &desc->value, value, > value_len, offset, desc- >max_val_len)) > return g_dbus_create_error(msg, Applied, thanks. -- pozdrawiam Szymon Janc