Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1697347

Re: [PATCH] hamradio: dmascc: avoid -Wformat-overflow warning

From David Miller <davem@davemloft.net>
Newsgroups linux.kernel
Subject Re: [PATCH] hamradio: dmascc: avoid -Wformat-overflow warning
Date 2017-07-26 18:50 +0200
Message-ID <u7xFv-2JL-1@gated-at.bofh.it> (permalink)
References <u7poD-5Va-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 26 Jul 2017 09:55:33 +0200

> gcc warns that the device name might overflow:
> 
> drivers/net/hamradio/dmascc.c: In function 'dmascc_init':
> drivers/net/hamradio/dmascc.c:584:22: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
>    sprintf(dev->name, "dmascc%i", 2 * n + i);
> drivers/net/hamradio/dmascc.c:584:3: note: 'sprintf' output between 8 and 17 bytes into a destination of size 16
>    sprintf(dev->name, "dmascc%i", 2 * n + i);
> 
> From the static data in this file, I can tell that the index is
> strictly limited to 16, so it won't overflow. This simply changes
> the sprintf() to snprintf(), which is a good idea in general,
> and shuts up this warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied to net-next.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] hamradio: dmascc: avoid -Wformat-overflow warning Arnd Bergmann <arnd@arndb.de> - 2017-07-26 10:00 +0200
  Re: [PATCH] hamradio: dmascc: avoid -Wformat-overflow warning David Miller <davem@davemloft.net> - 2017-07-26 18:50 +0200

csiph-web