diff mbox series

[rt-tests,v1,v1,2/4] sigwaittest: Increase buffer to avoid overflow

Message ID 20190819064304.4676-3-wagi@monom.org
State New
Headers show
Series Fix gcc warning | expand

Commit Message

Daniel Wagner Aug. 19, 2019, 6:43 a.m. UTC
Increase the size of the char buffer. gcc 9.1.1 reports:

src/sigwaittest/sigwaittest.c:494:5: note: ‘sprintf’ output between 5 and 14 bytes into a destination of size 8
  494 |     sprintf(f_opt, "-fr%d", i);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/sigwaittest/sigwaittest.c:522:24: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 5 [-Wformat-overflow=]
  522 |     sprintf(f_opt, "-fs%d", i);
      |                        ^~

Signed-off-by: Daniel Wagner <wagi@monom.org>

---
 src/sigwaittest/sigwaittest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.21.0

Comments

John Kacur Aug. 23, 2019, 3:17 p.m. UTC | #1
On Mon, 19 Aug 2019, Daniel Wagner wrote:

> Increase the size of the char buffer. gcc 9.1.1 reports:

> 

> src/sigwaittest/sigwaittest.c:494:5: note: ‘sprintf’ output between 5 and 14 bytes into a destination of size 8

>   494 |     sprintf(f_opt, "-fr%d", i);

>       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~

> src/sigwaittest/sigwaittest.c:522:24: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 5 [-Wformat-overflow=]

>   522 |     sprintf(f_opt, "-fs%d", i);

>       |                        ^~

> 

> Signed-off-by: Daniel Wagner <wagi@monom.org>

> ---

>  src/sigwaittest/sigwaittest.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c

> index 59f28a5babcb..2d0c04132fa7 100644

> --- a/src/sigwaittest/sigwaittest.c

> +++ b/src/sigwaittest/sigwaittest.c

> @@ -352,7 +352,7 @@ int main(int argc, char *argv[])

>  	struct params *sender = NULL;

>  	sigset_t sigset;

>  	void *param = NULL;

> -	char f_opt[8];

> +	char f_opt[14];

>  	struct timespec launchdelay, maindelay;

>  

>  	process_options(argc, argv);

> -- 

> 2.21.0

> 

Signed-off-by: John Kacur <jkacur@redhat.com>
diff mbox series

Patch

diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index 59f28a5babcb..2d0c04132fa7 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -352,7 +352,7 @@  int main(int argc, char *argv[])
 	struct params *sender = NULL;
 	sigset_t sigset;
 	void *param = NULL;
-	char f_opt[8];
+	char f_opt[14];
 	struct timespec launchdelay, maindelay;
 
 	process_options(argc, argv);