buildroot.busybox.net archive mirror
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/kconfig: fix compiler warnings
@ 2021-09-22 14:08 Edgar Bonet
  2021-10-06 19:23 ` Arnout Vandecappelle
  0 siblings, 1 reply; 3+ messages in thread
From: Edgar Bonet @ 2021-09-22 14:08 UTC (permalink / raw)
  To: buildroot

Compiling on Ubuntu 20.04 generates this:

./util.c: In function ‘file_write_dep’
./util.c:54:18: warning: ‘..config.tmp’ directive writing 12 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
   54 |  sprintf(buf, "%s..config.tmp", dir);
      |                  ^~~~~~~~~~~~
./util.c:54:2: note: ‘sprintf’ output between 13 and 4109 bytes into a destination of size 4097
   54 |  sprintf(buf, "%s..config.tmp", dir);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and similar warnings on confdata.c, lines 778, 989, 995, 1000, 1007,
1040, 1046 and 1054. Avoid the warnings by enlarging the destination
buffer of fprintf().

Signed-off-by: Edgar Bonet <bonet@grenoble.cnrs.fr>
---
 support/kconfig/confdata.c | 4 ++--
 support/kconfig/util.c     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/support/kconfig/confdata.c b/support/kconfig/confdata.c
index 892da74fdc..9ab980edd8 100644
--- a/support/kconfig/confdata.c
+++ b/support/kconfig/confdata.c
@@ -744,7 +744,7 @@ int conf_write(const char *name)
 	struct menu *menu;
 	const char *basename;
 	const char *str;
-	char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
+	char dirname[PATH_MAX+1], tmpname[PATH_MAX+20], newname[PATH_MAX+1];
 	char *env;
 
 	if (!name)
@@ -974,7 +974,7 @@ int conf_write_autoconf(void)
 	const char *name;
 	FILE *out, *tristate, *out_h;
 	int i;
-	char dir[PATH_MAX+1], buf[PATH_MAX+1];
+	char dir[PATH_MAX+1], buf[PATH_MAX+20];
 	char *s;
 
 	strcpy(dir, conf_get_configname());
diff --git a/support/kconfig/util.c b/support/kconfig/util.c
index 18a8e52391..8665f5bb89 100644
--- a/support/kconfig/util.c
+++ b/support/kconfig/util.c
@@ -35,7 +35,7 @@ struct file *file_lookup(const char *name)
 int file_write_dep(const char *name)
 {
 	char *str;
-	char buf[PATH_MAX+1], buf2[PATH_MAX+1], dir[PATH_MAX+1];
+	char buf[PATH_MAX+20], buf2[PATH_MAX+1], dir[PATH_MAX+1];
 	struct symbol *sym, *env_sym;
 	struct expr *e;
 	struct file *file;
-- 
2.25.1
_______________________________________________
buildroot mailing list
buildroot@lists.buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] support/kconfig: fix compiler warnings
  2021-09-22 14:08 [Buildroot] [PATCH 1/1] support/kconfig: fix compiler warnings Edgar Bonet
@ 2021-10-06 19:23 ` Arnout Vandecappelle
  2021-10-07  6:22   ` Peter Korsgaard
  0 siblings, 1 reply; 3+ messages in thread
From: Arnout Vandecappelle @ 2021-10-06 19:23 UTC (permalink / raw)
  To: Edgar Bonet, buildroot



On 22/09/2021 16:08, Edgar Bonet wrote:
> Compiling on Ubuntu 20.04 generates this:
> 
> ./util.c: In function ‘file_write_dep’
> ./util.c:54:18: warning: ‘..config.tmp’ directive writing 12 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
>     54 |  sprintf(buf, "%s..config.tmp", dir);
>        |                  ^~~~~~~~~~~~
> ./util.c:54:2: note: ‘sprintf’ output between 13 and 4109 bytes into a destination of size 4097
>     54 |  sprintf(buf, "%s..config.tmp", dir);
>        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> and similar warnings on confdata.c, lines 778, 989, 995, 1000, 1007,
> 1040, 1046 and 1054. Avoid the warnings by enlarging the destination
> buffer of fprintf().
> 
> Signed-off-by: Edgar Bonet <bonet@grenoble.cnrs.fr>
> ---
>   support/kconfig/confdata.c | 4 ++--
>   support/kconfig/util.c     | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)

  Normally, when we make changes to the kconfig sources, we want to keep track 
of that with patches in support/kconfig/patches. This allows us to track 
upstream without loosing the modifications we make.

  However, in this case, upstream has already heavily modified those files, and 
fixed the issues. So we there's no need to keep it as patches.

  Therefore, applied to master, with an updated commit message that explains the 
above, thanks.

  Regards,
  Arnout

> 
> diff --git a/support/kconfig/confdata.c b/support/kconfig/confdata.c
> index 892da74fdc..9ab980edd8 100644
> --- a/support/kconfig/confdata.c
> +++ b/support/kconfig/confdata.c
> @@ -744,7 +744,7 @@ int conf_write(const char *name)
>   	struct menu *menu;
>   	const char *basename;
>   	const char *str;
> -	char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
> +	char dirname[PATH_MAX+1], tmpname[PATH_MAX+20], newname[PATH_MAX+1];
>   	char *env;
>   
>   	if (!name)
> @@ -974,7 +974,7 @@ int conf_write_autoconf(void)
>   	const char *name;
>   	FILE *out, *tristate, *out_h;
>   	int i;
> -	char dir[PATH_MAX+1], buf[PATH_MAX+1];
> +	char dir[PATH_MAX+1], buf[PATH_MAX+20];
>   	char *s;
>   
>   	strcpy(dir, conf_get_configname());
> diff --git a/support/kconfig/util.c b/support/kconfig/util.c
> index 18a8e52391..8665f5bb89 100644
> --- a/support/kconfig/util.c
> +++ b/support/kconfig/util.c
> @@ -35,7 +35,7 @@ struct file *file_lookup(const char *name)
>   int file_write_dep(const char *name)
>   {
>   	char *str;
> -	char buf[PATH_MAX+1], buf2[PATH_MAX+1], dir[PATH_MAX+1];
> +	char buf[PATH_MAX+20], buf2[PATH_MAX+1], dir[PATH_MAX+1];
>   	struct symbol *sym, *env_sym;
>   	struct expr *e;
>   	struct file *file;
> 
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH 1/1] support/kconfig: fix compiler warnings
  2021-10-06 19:23 ` Arnout Vandecappelle
@ 2021-10-07  6:22   ` Peter Korsgaard
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2021-10-07  6:22 UTC (permalink / raw)
  To: Arnout Vandecappelle; +Cc: Edgar Bonet, buildroot

>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:

 > On 22/09/2021 16:08, Edgar Bonet wrote:
 >> Compiling on Ubuntu 20.04 generates this:
 >> 
 >> ./util.c: In function ‘file_write_dep’
 >> ./util.c:54:18: warning: ‘..config.tmp’ directive writing 12 bytes
 >> into a region of size between 1 and 4097 [-Wformat-overflow=]
 >> 54 |  sprintf(buf, "%s..config.tmp", dir);
 >> |                  ^~~~~~~~~~~~
 >> ./util.c:54:2: note: ‘sprintf’ output between 13 and 4109 bytes into a destination of size 4097
 >> 54 |  sprintf(buf, "%s..config.tmp", dir);
 >> |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 >> 
 >> and similar warnings on confdata.c, lines 778, 989, 995, 1000, 1007,
 >> 1040, 1046 and 1054. Avoid the warnings by enlarging the destination
 >> buffer of fprintf().
 >> 
 >> Signed-off-by: Edgar Bonet <bonet@grenoble.cnrs.fr>
 >> ---
 >> support/kconfig/confdata.c | 4 ++--
 >> support/kconfig/util.c     | 2 +-
 >> 2 files changed, 3 insertions(+), 3 deletions(-)

 >  Normally, when we make changes to the kconfig sources, we want to
 > keep track of that with patches in support/kconfig/patches. This
 > allows us to track upstream without loosing the modifications we make.

 >  However, in this case, upstream has already heavily modified those
 > files, and fixed the issues. So we there's no need to keep it as
 > patches.

 >  Therefore, applied to master, with an updated commit message that
 > explains the above, thanks.

Committed to 2021.02.x, 2021.05.x and 2021.08.x, thanks.

Maybe it is time to resync out kconfig copy?

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2021-10-07  6:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22 14:08 [Buildroot] [PATCH 1/1] support/kconfig: fix compiler warnings Edgar Bonet
2021-10-06 19:23 ` Arnout Vandecappelle
2021-10-07  6:22   ` Peter Korsgaard

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).