siemens: avoid out of bound access
PATCH 1/1 siemens: avoid out of bound access
char num[1]; sprintf(num, "%d", i);
leads to a buffer overrun.
Simplify the overly complex coding.
Signed-off-by Heinrich Schuchardt <[email protected]>
--- board/siemens/common/board.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
board/siemens/common/board.c +1 -4
@@ -189,14 +189,11 @@ void set_env_gpios(unsigned char state) {char *ptr_env;char str_tmp[5 ];/* must contain "ledX"*/ -char num[1 ];unsigned char i, idx, pos1, pos2, ccount;unsigned char gpio_n, gpio_s0, gpio_s1;for (i =0 ; i <MAX_NR_LEDS ; i++) { -strcpy (str_tmp,"led" ); -sprintf (num,"%d" , i); -strcat (str_tmp, num); +sprintf (str_tmp,"led%d" , i);/* If env var is not found we stop */ ptr_env =env_get (str_tmp);
--
2.20.1
PATCH 1/1 siemens: avoid out of bound access
Quoted 4 lines · Heinrich Schuchardt
char num[1];
sprintf(num, "%d", i);Quoted 9 lines
leads to a buffer overrun.
Simplify the overly complex coding.
Signed-off-by Heinrich Schuchardt <[email protected]>--- board/siemens/common/board.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Reviewed-by Bin Meng <[email protected]>
PATCH 1/1 siemens: avoid out of bound access
In reply to Heinrich SchuchardtHello Heinrich,
Am 22.08.2019 um 21:58 schrieb Heinrich Schuchardt:
Quoted 11 lines
char num[1]; sprintf(num, "%d", i);leads to a buffer overrun.
Simplify the overly complex coding.
Signed-off-by Heinrich Schuchardt <[email protected]>--- board/siemens/common/board.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
Thanks!
Acked-by Heiko Schocher <[email protected]>
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/1 siemens: avoid out of bound access
In reply to Heinrich SchuchardtQuoted 10 lines · Heinrich Schuchardt
char num[1]; sprintf(num, "%d", i);leads to a buffer overrun.
Simplify the overly complex coding.
Signed-off-by Heinrich Schuchardt <[email protected]>Reviewed-by Bin Meng <[email protected]>Acked-by Heiko Schocher <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190902/b7dd7f35/attachment.sig>