All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] monitor: Fix truncated server socket path parameter
@ 2021-08-04  8:59 Mariusz Skamra
  2021-08-04  9:39 ` bluez.test.bot
  2021-08-04 10:54 ` [PATCH v2] " Mariusz Skamra
  0 siblings, 2 replies; 5+ messages in thread
From: Mariusz Skamra @ 2021-08-04  8:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mariusz Skamra

This fixes the issue of --server <socket> 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: monitor: Fix truncated server socket path parameter
  2021-08-04  8:59 [PATCH] monitor: Fix truncated server socket path parameter Mariusz Skamra
@ 2021-08-04  9:39 ` bluez.test.bot
  2021-08-04 10:54 ` [PATCH v2] " Mariusz Skamra
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2021-08-04  9:39 UTC (permalink / raw)
  To: linux-bluetooth, mariusz.skamra

[-- Attachment #1: Type: text/plain, Size: 2734 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=526107

---Test result---

Test Summary:
CheckPatch                    FAIL      0.39 seconds
GitLint                       PASS      0.12 seconds
Prep - Setup ELL              PASS      46.93 seconds
Build - Prep                  PASS      0.15 seconds
Build - Configure             PASS      8.18 seconds
Build - Make                  PASS      213.24 seconds
Make Check                    PASS      9.51 seconds
Make Distcheck                PASS      250.91 seconds
Build w/ext ELL - Configure   PASS      8.58 seconds
Build w/ext ELL - Make        PASS      204.29 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
monitor: Fix truncated server socket path parameter
ERROR:GERRIT_CHANGE_ID: Remove Gerrit Change-Id's before submitting upstream
#11: 
Change-Id: I646f86709d59d33b8f1d27b725eb42a9f44f6f2d

- total: 1 errors, 0 warnings, 23 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] monitor: Fix truncated server socket path parameter" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] monitor: Fix truncated server socket path parameter
  2021-08-04  8:59 [PATCH] monitor: Fix truncated server socket path parameter Mariusz Skamra
  2021-08-04  9:39 ` bluez.test.bot
@ 2021-08-04 10:54 ` Mariusz Skamra
  2021-08-04 11:30   ` [v2] " bluez.test.bot
  2021-08-04 14:53   ` [PATCH v2] " Szymon Janc
  1 sibling, 2 replies; 5+ messages in thread
From: Mariusz Skamra @ 2021-08-04 10:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Mariusz Skamra

This fixes the issue of --server <socket> 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
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [v2] monitor: Fix truncated server socket path parameter
  2021-08-04 10:54 ` [PATCH v2] " Mariusz Skamra
@ 2021-08-04 11:30   ` bluez.test.bot
  2021-08-04 14:53   ` [PATCH v2] " Szymon Janc
  1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2021-08-04 11:30 UTC (permalink / raw)
  To: linux-bluetooth, mariusz.skamra

[-- Attachment #1: Type: text/plain, Size: 1953 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=526191

---Test result---

Test Summary:
CheckPatch                    PASS      0.27 seconds
GitLint                       PASS      0.11 seconds
Prep - Setup ELL              PASS      40.73 seconds
Build - Prep                  PASS      0.10 seconds
Build - Configure             PASS      7.15 seconds
Build - Make                  PASS      178.63 seconds
Make Check                    PASS      9.18 seconds
Make Distcheck                PASS      210.60 seconds
Build w/ext ELL - Configure   PASS      7.26 seconds
Build w/ext ELL - Make        PASS      168.20 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] monitor: Fix truncated server socket path parameter
  2021-08-04 10:54 ` [PATCH v2] " Mariusz Skamra
  2021-08-04 11:30   ` [v2] " bluez.test.bot
@ 2021-08-04 14:53   ` Szymon Janc
  1 sibling, 0 replies; 5+ messages in thread
From: Szymon Janc @ 2021-08-04 14:53 UTC (permalink / raw)
  To: linux-bluetooth, Mariusz Skamra; +Cc: Mariusz Skamra

Hello Mariusz,

On Wednesday, 4 August 2021 12:54:46 CEST Mariusz Skamra wrote:
> This fixes the issue of --server <socket> 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
> ---
>  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");

Patch applied, thanks.

-- 
pozdrawiam
Szymon Janc



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-04 14:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04  8:59 [PATCH] monitor: Fix truncated server socket path parameter Mariusz Skamra
2021-08-04  9:39 ` bluez.test.bot
2021-08-04 10:54 ` [PATCH v2] " Mariusz Skamra
2021-08-04 11:30   ` [v2] " bluez.test.bot
2021-08-04 14:53   ` [PATCH v2] " Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.