All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib: -Wformat-truncation in rsa_engine_get_priv_key
@ 2021-07-30 15:05 Heinrich Schuchardt
  2021-07-31 16:59 ` Simon Glass
  2021-09-02 13:28 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2021-07-30 15:05 UTC (permalink / raw)
  To: u-boot; +Cc: Marc Kleine-Budde, Chan, Donald, Alexandru Gagniuc, Simon Glass

With glibc 2.33 (Ubuntu package glibc6 2.33-0ubuntu9) building
sifive_unmatched_defconfig results in:

In file included from /usr/include/stdio.h:866,
                  from ././include/compiler.h:26,
                  from <command-line>:
In function ‘snprintf’,
     inlined from ‘rsa_engine_get_priv_key’ at ./tools/../^:273:4:
/usr/include/riscv64-linux-gnu/bits/stdio2.h:71:10: warning:
‘%s’ directive argument is null [-Wformat-truncation=]
    71 |   return __builtin___snprintf_chk (__s, __n, 
__USE_FORTIFY_LEVEL - 1,
       | 
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    72 |        __glibc_objsize (__s), __fmt,
       |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    73 |        __va_arg_pack ());
       |        ~~~~~~~~~~~~~~~~~

Avoid passing a NULL string.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
  lib/rsa/rsa-sign.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
index 085dc89bf7..c7ae7a0dbc 100644
--- a/lib/rsa/rsa-sign.c
+++ b/lib/rsa/rsa-sign.c
@@ -271,8 +271,7 @@ static int rsa_engine_get_priv_key(const char 
*keydir, const char *name,
  				 keydir, name);
  		else if (keydir)
  			snprintf(key_id, sizeof(key_id),
-				 "%s",
-				 name);
+				 "%s", name ? name : "");
  		else if (keyfile)
  			snprintf(key_id, sizeof(key_id), "%s", keyfile);
  		else
-- 
2.31.1


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

* Re: [PATCH] lib: -Wformat-truncation in rsa_engine_get_priv_key
  2021-07-30 15:05 [PATCH] lib: -Wformat-truncation in rsa_engine_get_priv_key Heinrich Schuchardt
@ 2021-07-31 16:59 ` Simon Glass
  2021-09-02 13:28 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-07-31 16:59 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: U-Boot Mailing List, Marc Kleine-Budde, Chan, Donald, Alexandru Gagniuc

On Fri, 30 Jul 2021 at 09:05, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> With glibc 2.33 (Ubuntu package glibc6 2.33-0ubuntu9) building
> sifive_unmatched_defconfig results in:
>
> In file included from /usr/include/stdio.h:866,
>                   from ././include/compiler.h:26,
>                   from <command-line>:
> In function ‘snprintf’,
>      inlined from ‘rsa_engine_get_priv_key’ at ./tools/../^:273:4:
> /usr/include/riscv64-linux-gnu/bits/stdio2.h:71:10: warning:
> ‘%s’ directive argument is null [-Wformat-truncation=]
>     71 |   return __builtin___snprintf_chk (__s, __n,
> __USE_FORTIFY_LEVEL - 1,
>        |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     72 |        __glibc_objsize (__s), __fmt,
>        |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     73 |        __va_arg_pack ());
>        |        ~~~~~~~~~~~~~~~~~
>
> Avoid passing a NULL string.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>   lib/rsa/rsa-sign.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH] lib: -Wformat-truncation in rsa_engine_get_priv_key
  2021-07-30 15:05 [PATCH] lib: -Wformat-truncation in rsa_engine_get_priv_key Heinrich Schuchardt
  2021-07-31 16:59 ` Simon Glass
@ 2021-09-02 13:28 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2021-09-02 13:28 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: u-boot, Marc Kleine-Budde, Chan, Donald, Alexandru Gagniuc, Simon Glass

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

On Fri, Jul 30, 2021 at 05:05:07PM +0200, Heinrich Schuchardt wrote:

> With glibc 2.33 (Ubuntu package glibc6 2.33-0ubuntu9) building
> sifive_unmatched_defconfig results in:
> 
> In file included from /usr/include/stdio.h:866,
>                   from ././include/compiler.h:26,
>                   from <command-line>:
> In function ‘snprintf’,
>      inlined from ‘rsa_engine_get_priv_key’ at ./tools/../^:273:4:
> /usr/include/riscv64-linux-gnu/bits/stdio2.h:71:10: warning:
> ‘%s’ directive argument is null [-Wformat-truncation=]
>     71 |   return __builtin___snprintf_chk (__s, __n, 
> __USE_FORTIFY_LEVEL - 1,
>        | 
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     72 |        __glibc_objsize (__s), __fmt,
>        |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     73 |        __va_arg_pack ());
>        |        ~~~~~~~~~~~~~~~~~
> 
> Avoid passing a NULL string.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2021-09-02 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 15:05 [PATCH] lib: -Wformat-truncation in rsa_engine_get_priv_key Heinrich Schuchardt
2021-07-31 16:59 ` Simon Glass
2021-09-02 13:28 ` Tom Rini

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.