linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] depmod: Fix writing over array length
@ 2022-06-03 20:49 Lucas De Marchi
  2022-06-03 20:49 ` [PATCH 2/2] modprobe: re-use modname variable Lucas De Marchi
  2022-06-27 16:42 ` [PATCH 1/2] depmod: Fix writing over array length Lucas De Marchi
  0 siblings, 2 replies; 3+ messages in thread
From: Lucas De Marchi @ 2022-06-03 20:49 UTC (permalink / raw)
  To: linux-modules; +Cc: Lucas De Marchi

Make sure return value in flush_stream_to() is the length written
if the value didn't the size. Fix warning on gcc 12.1:

	tools/depmod.c: In function ‘output_builtin_alias_bin’:
	tools/depmod.c:2465:24: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds]
	 2465 |                 modname[len] = '\0';
	      |                 ~~~~~~~^~~~~
	tools/depmod.c:2460:22: note: while referencing ‘modname’
	 2460 |                 char modname[PATH_MAX];
	      |                      ^~~~~~~
	tools/depmod.c:2477:22: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds]
	 2477 |                 value[len] = '\0';
	      |                 ~~~~~^~~~~
	tools/depmod.c:2461:22: note: while referencing ‘value’
	 2461 |                 char value[PATH_MAX];
	      |                      ^~~~~

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
---
 tools/depmod.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/depmod.c b/tools/depmod.c
index 4117dd1..364b7d4 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2430,6 +2430,7 @@ static int flush_stream_to(FILE *in, int endchar, char *dst, size_t dst_sz)
 	if (i == dst_sz) {
 		WRN("Could not flush stream: %d. Partial content: %.*s\n",
 		    ENOSPC, (int) dst_sz, dst);
+		i--;
 	}
 
 	return c == endchar ? i : 0;
-- 
2.36.1


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

* [PATCH 2/2] modprobe: re-use modname variable
  2022-06-03 20:49 [PATCH 1/2] depmod: Fix writing over array length Lucas De Marchi
@ 2022-06-03 20:49 ` Lucas De Marchi
  2022-06-27 16:42 ` [PATCH 1/2] depmod: Fix writing over array length Lucas De Marchi
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas De Marchi @ 2022-06-03 20:49 UTC (permalink / raw)
  To: linux-modules; +Cc: Lucas De Marchi

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
---
 tools/modprobe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/modprobe.c b/tools/modprobe.c
index 830c667..a825fb5 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -324,7 +324,7 @@ static int rmmod_do_remove_module(struct kmod_module *mod)
 	const char *modname = kmod_module_get_name(mod);
 	int flags = 0, err;
 
-	SHOW("rmmod %s\n", kmod_module_get_name(mod));
+	SHOW("rmmod %s\n", modname);
 
 	if (dry_run)
 		return 0;
-- 
2.36.1


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

* Re: [PATCH 1/2] depmod: Fix writing over array length
  2022-06-03 20:49 [PATCH 1/2] depmod: Fix writing over array length Lucas De Marchi
  2022-06-03 20:49 ` [PATCH 2/2] modprobe: re-use modname variable Lucas De Marchi
@ 2022-06-27 16:42 ` Lucas De Marchi
  1 sibling, 0 replies; 3+ messages in thread
From: Lucas De Marchi @ 2022-06-27 16:42 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-modules

These 2 patches are now applied.

Lucas De Marchi

On Fri, Jun 03, 2022 at 01:49:01PM -0700, Lucas De Marchi wrote:
>Make sure return value in flush_stream_to() is the length written
>if the value didn't the size. Fix warning on gcc 12.1:
>
>	tools/depmod.c: In function ‘output_builtin_alias_bin’:
>	tools/depmod.c:2465:24: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds]
>	 2465 |                 modname[len] = '\0';
>	      |                 ~~~~~~~^~~~~
>	tools/depmod.c:2460:22: note: while referencing ‘modname’
>	 2460 |                 char modname[PATH_MAX];
>	      |                      ^~~~~~~
>	tools/depmod.c:2477:22: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds]
>	 2477 |                 value[len] = '\0';
>	      |                 ~~~~~^~~~~
>	tools/depmod.c:2461:22: note: while referencing ‘value’
>	 2461 |                 char value[PATH_MAX];
>	      |                      ^~~~~
>
>Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
>---
> tools/depmod.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/tools/depmod.c b/tools/depmod.c
>index 4117dd1..364b7d4 100644
>--- a/tools/depmod.c
>+++ b/tools/depmod.c
>@@ -2430,6 +2430,7 @@ static int flush_stream_to(FILE *in, int endchar, char *dst, size_t dst_sz)
> 	if (i == dst_sz) {
> 		WRN("Could not flush stream: %d. Partial content: %.*s\n",
> 		    ENOSPC, (int) dst_sz, dst);
>+		i--;
> 	}
>
> 	return c == endchar ? i : 0;
>-- 
>2.36.1
>

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

end of thread, other threads:[~2022-06-27 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 20:49 [PATCH 1/2] depmod: Fix writing over array length Lucas De Marchi
2022-06-03 20:49 ` [PATCH 2/2] modprobe: re-use modname variable Lucas De Marchi
2022-06-27 16:42 ` [PATCH 1/2] depmod: Fix writing over array length Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).