CVS commit: src/usr.bin/sockstat

2021-08-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Aug 27 18:09:30 UTC 2021

Modified Files:
src/usr.bin/sockstat: sockstat.c

Log Message:
sockstat: fix undefined behavior when calling ctype functions

lint says: warning: argument to 'function from ' must be cast
to 'unsigned char', not to 'unsigned int' [342]


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/sockstat/sockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/sockstat/sockstat.c
diff -u src/usr.bin/sockstat/sockstat.c:1.23 src/usr.bin/sockstat/sockstat.c:1.24
--- src/usr.bin/sockstat/sockstat.c:1.23	Wed Aug 26 22:57:55 2020
+++ src/usr.bin/sockstat/sockstat.c	Fri Aug 27 18:09:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockstat.c,v 1.23 2020/08/26 22:57:55 christos Exp $ */
+/*	$NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: sockstat.c,v 1.23 2020/08/26 22:57:55 christos Exp $");
+__RCSID("$NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $");
 #endif
 
 #define _KMEMUSER
@@ -275,7 +275,7 @@ get_num(const char *l, const char **s, c
 	long x;
 	char *t;
 
-	while (isdigit((u_int)**e))
+	while (isdigit((unsigned char)**e))
 		(*e)++;
 	if (*s != *e) {
 		errno = 0;



CVS commit: src/usr.bin/sockstat

2021-08-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Aug 27 18:09:30 UTC 2021

Modified Files:
src/usr.bin/sockstat: sockstat.c

Log Message:
sockstat: fix undefined behavior when calling ctype functions

lint says: warning: argument to 'function from ' must be cast
to 'unsigned char', not to 'unsigned int' [342]


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/sockstat/sockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.bin/sockstat

2020-08-26 Thread Simon Burge
"Christos Zoulas" wrote:

> Module Name:  src
> Committed By: christos
> Date: Wed Aug 26 22:57:56 UTC 2020
>
> Modified Files:
>
>   src/usr.bin/sockstat: Makefile sockstat.c
>
> Log Message:
>
> undo previous, now sockstat works without privs

Nice, thanks Christos!

Cheers,
Simon.


CVS commit: src/usr.bin/sockstat

2019-08-17 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Aug 18 04:13:24 UTC 2019

Modified Files:
src/usr.bin/sockstat: Makefile prog_ops.h sockstat.c sockstat_hostops.c
sockstat_rumpops.c

Log Message:
sockstat: Add indirection of symbols to remove clash with sanitizers

Add indirection and symbol renaming under MKSANITIZER for the linked in
version of sysctlgetmibinfo and sysctlnametomib.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/sockstat/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/sockstat/prog_ops.h \
src/usr.bin/sockstat/sockstat_hostops.c \
src/usr.bin/sockstat/sockstat_rumpops.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/sockstat/sockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/sockstat

2019-08-17 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Aug 18 04:13:24 UTC 2019

Modified Files:
src/usr.bin/sockstat: Makefile prog_ops.h sockstat.c sockstat_hostops.c
sockstat_rumpops.c

Log Message:
sockstat: Add indirection of symbols to remove clash with sanitizers

Add indirection and symbol renaming under MKSANITIZER for the linked in
version of sysctlgetmibinfo and sysctlnametomib.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/sockstat/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/sockstat/prog_ops.h \
src/usr.bin/sockstat/sockstat_hostops.c \
src/usr.bin/sockstat/sockstat_rumpops.c
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/sockstat/sockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/sockstat/Makefile
diff -u src/usr.bin/sockstat/Makefile:1.3 src/usr.bin/sockstat/Makefile:1.4
--- src/usr.bin/sockstat/Makefile:1.3	Fri Jan 28 18:52:49 2011
+++ src/usr.bin/sockstat/Makefile	Sun Aug 18 04:13:24 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2011/01/28 18:52:49 pooka Exp $
+#	$NetBSD: Makefile,v 1.4 2019/08/18 04:13:24 kamil Exp $
 
 .include 
 
@@ -8,6 +8,10 @@ RUMPPRG=	sockstat
 CPPFLAGS+= -DRUMP_ACTION
 RUMPSRCS+=	sysctlgetmibinfo.c sysctlnametomib.c
 
+SANITIZER_RENAME_CLASSES+=	rump
+SANITIZER_RENAME_FILES.rump+=	${PROG}_rumpops.c ${RUMPSRCS}
+SANITIZER_RENAME_SYMBOL.rump+=	sysctlgetmibinfo sysctlnametomib
+
 .if (${USE_INET6} != "no")
 CPPFLAGS+=-DINET6
 .endif

Index: src/usr.bin/sockstat/prog_ops.h
diff -u src/usr.bin/sockstat/prog_ops.h:1.1 src/usr.bin/sockstat/prog_ops.h:1.2
--- src/usr.bin/sockstat/prog_ops.h:1.1	Fri Jan 28 18:52:49 2011
+++ src/usr.bin/sockstat/prog_ops.h	Sun Aug 18 04:13:24 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: prog_ops.h,v 1.1 2011/01/28 18:52:49 pooka Exp $	*/
+/*  $NetBSD: prog_ops.h,v 1.2 2019/08/18 04:13:24 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -32,19 +32,32 @@
 #include 
 
 #ifndef CRUNCHOPS
+struct sysctlnode;
+
 struct prog_ops {
 	int (*op_init)(void);
 
 	int (*op_sysctl)(const int *, u_int, void *, size_t *,
 			 const void *, size_t);
+
+	/* Indirection needed for sanitizers. */
+
+	int (*op_sysctlgetmibinfo)(const char *, int *, u_int *, char *,
+			 size_t *, struct sysctlnode **, int);
+
+	int (*op_sysctlnametomib)(const char *, int *, size_t *);
 };
 extern const struct prog_ops prog_ops;
 
 #define prog_init prog_ops.op_init
 #define prog_sysctl prog_ops.op_sysctl
+#define prog_sysctlgetmibinfo prog_ops.op_sysctlgetmibinfo
+#define prog_sysctlnametomib prog_ops.op_sysctlnametomib
 #else
 #define prog_init ((int (*)(void))NULL)
 #define prog_sysctl sysctl
+#define prog_sysctlgetmibinfo sysctlgetmibinfo
+#define prog_sysctlnametomib sysctlnametomib
 #endif
 
 #endif /* _PROG_OPS_H_ */
Index: src/usr.bin/sockstat/sockstat_hostops.c
diff -u src/usr.bin/sockstat/sockstat_hostops.c:1.1 src/usr.bin/sockstat/sockstat_hostops.c:1.2
--- src/usr.bin/sockstat/sockstat_hostops.c:1.1	Fri Jan 28 18:52:49 2011
+++ src/usr.bin/sockstat/sockstat_hostops.c	Sun Aug 18 04:13:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockstat_hostops.c,v 1.1 2011/01/28 18:52:49 pooka Exp $	*/
+/*	$NetBSD: sockstat_hostops.c,v 1.2 2019/08/18 04:13:24 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: sockstat_hostops.c,v 1.1 2011/01/28 18:52:49 pooka Exp $");
+__RCSID("$NetBSD: sockstat_hostops.c,v 1.2 2019/08/18 04:13:24 kamil Exp $");
 #endif /* !lint */
 
 #include 
@@ -38,4 +38,8 @@ __RCSID("$NetBSD: sockstat_hostops.c,v 1
 
 const struct prog_ops prog_ops = {
 	.op_sysctl = sysctl,
+
+.op_sysctlgetmibinfo = sysctlgetmibinfo,
+
+.op_sysctlnametomib = sysctlnametomib,
 };
Index: src/usr.bin/sockstat/sockstat_rumpops.c
diff -u src/usr.bin/sockstat/sockstat_rumpops.c:1.1 src/usr.bin/sockstat/sockstat_rumpops.c:1.2
--- src/usr.bin/sockstat/sockstat_rumpops.c:1.1	Fri Jan 28 18:52:49 2011
+++ src/usr.bin/sockstat/sockstat_rumpops.c	Sun Aug 18 04:13:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sockstat_rumpops.c,v 1.1 2011/01/28 18:52:49 pooka Exp $	*/
+/*	$NetBSD: sockstat_rumpops.c,v 1.2 2019/08/18 04:13:24 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,10 +28,11 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: sockstat_rumpops.c,v 1.1 2011/01/28 18:52:49 pooka Exp $");
+__RCSID("$NetBSD: sockstat_rumpops.c,v 1.2 2019/08/18 04:13:24 kamil Exp $");
 #endif /* !lint */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -42,4 +43,8 @@ const struct prog_ops prog_ops = {
 	.op_init =	rumpclient_init,
 
 	.op_sysctl =	rump_sys___sysctl,
+
+	.op_sysctlgetmibinfo = sysctlgetmibinfo,
+
+	.op_sysctlnametomib = sysctlnametomib,
 };

Index: src/usr.bin/sockstat/sockstat.c
diff -u src/usr.bin/sockstat/sockstat.c:1.20 src/usr.bin/sockstat/sockstat.c:1.21
--- src/usr.bin/sockstat/socksta