Files
u-boot-sunxi/cmd
Alison Chaiken 2fcaa413b3 gpt: harden set_gpt_info() against non NULL-terminated strings
Strings read from devices may sometimes fail to be
NULL-terminated.   The functions in lib/string.c are subject to
failure in this case.   Protect against observed failures in
set_gpt_info() by switching to length-checking variants with a length
limit of the maximum possible partition table length.  At the same
time, add a few checks for NULL string pointers.

Here is an example as observed in sandbox under GDB:

    => gpt verify host 0 $partitions
    Program received signal SIGSEGV, Segmentation fault.
    0x0000000000477747 in strlen (s=0x0) at lib/string.c:267
    267             for (sc = s; *sc != '\0'; ++sc)
    (gdb) bt
    #0  0x0000000000477747 in strlen (s=0x0) at lib/string.c:267
    #1  0x00000000004140b2 in set_gpt_info (str_part=<optimized out>,
    str_disk_guid=str_disk_guid@entry=0x7fffffffdbe8, partitions=partitions@entry=0x7fffffffdbd8,
    parts_count=parts_count@entry=0x7fffffffdbcf "", dev_desc=<optimized out>) at cmd/gpt.c:415
    #2  0x00000000004145b9 in gpt_verify (str_part=<optimized out>, blk_dev_desc=0x7fffef09a9d0) at cmd/gpt.c:580
    #3  do_gpt (cmdtp=<optimized out>, flag=<optimized out>, argc=<optimized out>, argv=0x7fffef09a8f0)
    at cmd/gpt.c:783
    #4  0x00000000004295b0 in cmd_call (argv=0x7fffef09a8f0, argc=0x5, flag=<optimized out>,
    cmdtp=0x714e20 <_u_boot_list_2_cmd_2_gpt>) at common/command.c:500
    #5  cmd_process (flag=<optimized out>, argc=0x5, argv=0x7fffef09a8f0,
    repeatable=repeatable@entry=0x726c04 <flag_repeat>, ticks=ticks@entry=0x0) at common/command.c:539

Suggested-by: Lothar Waßmann <LW@karo-electronics.de>
Signed-off-by: Alison Chaiken <alison@peloton-tech.com>
2017-08-04 20:38:32 -04:00
..
2017-02-08 15:56:28 -05:00
2017-04-12 13:28:27 -04:00
2017-07-03 17:35:28 -04:00
2016-03-22 12:16:08 -04:00
2016-09-09 15:53:14 -04:00
2017-06-16 10:11:42 -04:00
2016-05-02 18:37:09 -04:00
2016-04-18 17:11:36 -04:00
2017-01-20 09:15:24 -05:00
2017-03-28 06:27:54 +02:00
2017-06-12 08:37:55 -04:00
2017-02-08 15:56:28 -05:00
2017-07-03 17:35:28 -04:00
2016-12-27 11:24:18 -05:00
2016-10-06 20:57:42 -04:00
2017-06-02 10:16:46 -06:00
2017-06-12 08:37:55 -04:00
2016-09-07 08:49:02 -04:00
2017-06-12 08:37:55 -04:00
2016-03-27 09:12:55 -04:00
2017-03-26 13:22:58 -06:00
2016-02-26 08:53:10 -07:00