Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp3124222pxy; Wed, 4 Aug 2021 03:01:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS6ID1aBHRLALJUnzXHYPiyLz+IPEppTZJJotWGCPOW/gPejda9uc6ug2io9DW5d2RNbKr X-Received: by 2002:a17:906:1f82:: with SMTP id t2mr24656947ejr.499.1628071268563; Wed, 04 Aug 2021 03:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628071268; cv=none; d=google.com; s=arc-20160816; b=IWeMDm25E2/gDZEHkyPqGu8N8FA1ftJN60Tr8FRU6UvfEXhisR8z9cWb6Eq5VFii60 RmM7qU3+eeAlR57eZpV6asEgTXOo7qx53O70kDnaeNbiEOXS0foiLapg26fRnjavwlvN UzHDg5V2/vvPPLC9C+XVUFxEt8m4d+7YR15RDJ9pDoSiyOAPMX/Z8pR7QGHX5BTSkSm7 VdrbQ9O8O24akdcTmXSZWrHSoUk0RtgQvdGdsQK6KxzgKIVsPtbxHavgITRmZEjj3JNk FaDQSxmAU9hZbRSVjOzI06lNxopQAq7BGm89r0e8FhT8WZ4UtqqMU6yqALwuwZG50bc5 MOGw== 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=J/jpn9E/qH0S6IgnbXP74qTOPR1UpoIfV7YCLmx1gaw=; b=n+mszHLm8Ugtxt3dPbrMETfmxQl/RAp47OLq4TlcMym/UK60Su1avbxEV4iSKfOqTg jsUeO19JwJtD6hRMIxNQ9ochYq+zYX6oaN1juNWGxu5lQSaX/0Atv4OetX5TfDUjo6OR OGtwdIcHhi6u+VIV+t10VZPINSNYVut1uz1kjueuwXMcOu9Qaf+SWo4egvFghqQwc92V /dmTtGwPhGzc3Y5o3w8uJZWiQ2eglF6ENlnBUFbH1p1leLzE0n44zOXa+M0vynLCoL1z tU2j3m3mm9ZC+CRHJfQJOon0O5gfWqR7UKA47GHw+f3cAQgaTU09QIYvhiZFQGedaZ3k t7Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codecoup-pl.20150623.gappssmtp.com header.s=20150623 header.b=lWBqs9f5; 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 c2si1621816edr.563.2021.08.04.03.00.24; Wed, 04 Aug 2021 03:01:08 -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=lWBqs9f5; 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 S235699AbhHDJAE (ORCPT + 99 others); Wed, 4 Aug 2021 05:00:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236876AbhHDJAD (ORCPT ); Wed, 4 Aug 2021 05:00:03 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C9C3C0613D5 for ; Wed, 4 Aug 2021 01:59:51 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id p38so3353230lfa.0 for ; Wed, 04 Aug 2021 01:59:50 -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:mime-version :content-transfer-encoding; bh=J/jpn9E/qH0S6IgnbXP74qTOPR1UpoIfV7YCLmx1gaw=; b=lWBqs9f5cglW3bH+fboI2bAPcsnnTYTDX5R0QI60YzNQjB5Z5z74uE773u6OXbnOPg dxiM6p2xrQt3H8dXQBIuYyd1GDrgz6DkWlqn7f0enCkH5aCtQpXvtPLpCzh4zU2sXWJ0 zBTa6t4WGMWfH9E1v+D99M2KQa2Hdsfq0S32pKbpg3QCZ0QtwvBeS39eFXZPqi3CzJaf hf3s9O0+r56F8FW47Yyyur32YNE9UdAksxmIDjrkKgYDWrnUZecarR2AEz6TlYN4qQix htNv7ztoXA/JLr//k5UK1bvkNE4bQzL6h6EHYAG4MwM1mS7ElUJHiGtSDuaa5rN5pYCA 9p+A== 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=J/jpn9E/qH0S6IgnbXP74qTOPR1UpoIfV7YCLmx1gaw=; b=Xn/TkUfcbwE/8LAmH+8M0Touv71t7Bbt5uQxAP4J0Odwl8wEa4J+h7t8kG9lbSW6ro 947tK+jreS2h+o7NPHnRIFmLsA1BhrspMo4Roqq/koSNc5volUPBGBDlKNMb5e+/qEyR H9WhGDFtRNbPqz8G6yxXmXJlXgZq5kJzAAfIZK9v7B8t6l9Mh47h9Irgi8vbB7QFO9X5 Xu+U5ibmMnQRM6ScVGT0592zWhvddDMPWktsI4E1ify1JX0H5z6nEjLanP/sX0rlcHfx axXFlPNIU4S8ftb43SoCbptfQI56EvH/WtJ65ZfgaXwjK7qxo6R2DThjX/68ldxR9xKd jMtg== X-Gm-Message-State: AOAM531TKWGi6cRE4AqYfFNxMpFCSsu8JwB1wg2VSyRF1KafjaGgPrdU 8zl3BPSoJzI518pVdkWnWl7DEZIOX2r4OQ== X-Received: by 2002:ac2:4c37:: with SMTP id u23mr11753315lfq.340.1628067589268; Wed, 04 Aug 2021 01:59:49 -0700 (PDT) Received: from localhost.localdomain ([95.143.243.62]) by smtp.gmail.com with ESMTPSA id i8sm138346lfu.55.2021.08.04.01.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 01:59:48 -0700 (PDT) From: Mariusz Skamra To: linux-bluetooth@vger.kernel.org Cc: Mariusz Skamra Subject: [PATCH] monitor: Fix truncated server socket path parameter Date: Wed, 4 Aug 2021 10:59:37 +0200 Message-Id: <20210804085937.541076-1-mariusz.skamra@codecoup.pl> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This fixes the issue of --server parameter last character was dropped. There is no need to use strncpy, as the length is already checked, and it is known that the destination buffer is big enough Change-Id: I646f86709d59d33b8f1d27b725eb42a9f44f6f2d --- monitor/control.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/monitor/control.c b/monitor/control.c index d1ba97d37..266602a34 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -1165,14 +1165,12 @@ static int server_fd = -1; void control_server(const char *path) { struct sockaddr_un addr; - size_t len; int fd; if (server_fd >= 0) return; - len = strlen(path); - if (len > sizeof(addr.sun_path) - 1) { + if (strlen(path) > sizeof(addr.sun_path) - 1) { fprintf(stderr, "Socket name too long\n"); return; } @@ -1187,7 +1185,7 @@ void control_server(const char *path) memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, path, len - 1); + strcpy(addr.sun_path, path); if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { perror("Failed to bind server socket"); -- 2.31.1