Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-flock / stx-metal / files / 0001-mtce-avoid-overflowing-amon.tx_buf.patch
1 From 3060369f60b2dc9e6d138cabd18d7f206c7bb0f5 Mon Sep 17 00:00:00 2001
2 From: babak sarashki <babak.sarashki@windriver.com>
3 Date: Thu, 27 Jun 2019 21:40:34 -0700
4 Subject: [PATCH] Use snprintf to avoid overflowing amon.tx_buf
5
6 ---
7  public/amon.c | 3 ++-
8  1 file changed, 2 insertions(+), 1 deletion(-)
9
10 diff --git a/public/amon.c b/public/amon.c
11 index b9146a2..941f905 100644
12 --- a/public/amon.c
13 +++ b/public/amon.c
14 @@ -257,7 +257,8 @@ int  active_monitor_dispatch ( void )
15              }
16  
17              memset ( amon.tx_buf, 0 , AMON_MAX_LEN );
18 -            sprintf( amon.tx_buf, "%s %8x %d%c", str, magic, seq, '\0' );
19 +            if (snprintf( amon.tx_buf, AMON_MAX_LEN,  "%s %8x %d%c", str, magic, seq, '\0' ) < 0)
20 +               fprintf(stderr,"%s:%d amon.txbuf overflow detected!\n", __func__, __LINE__);
21              
22              if ( strcmp ( str, amon.name ) )
23              {
24 -- 
25 2.17.1
26