Commit 8d99513c1b76cfd0b2dcf061c5136cb1061e6b37
Committed by
Rusty Russell
1 parent
d4703aefdb
Exists in
master
and in
39 other branches
modpost: fix segfault with short symbol names
memcmp() is wrong here, the symbol name can be shorter than KSYMTAB_PFX or CRC_PFX. Signed-off-by: Michal Marek <mmarek@suse.cz> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
scripts/mod/modpost.c
... | ... | @@ -522,7 +522,7 @@ |
522 | 522 | break; |
523 | 523 | case SHN_ABS: |
524 | 524 | /* CRC'd symbol */ |
525 | - if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { | |
525 | + if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { | |
526 | 526 | crc = (unsigned int) sym->st_value; |
527 | 527 | sym_update_crc(symname + strlen(CRC_PFX), mod, crc, |
528 | 528 | export); |
... | ... | @@ -566,7 +566,7 @@ |
566 | 566 | break; |
567 | 567 | default: |
568 | 568 | /* All exported symbols */ |
569 | - if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { | |
569 | + if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { | |
570 | 570 | sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, |
571 | 571 | export); |
572 | 572 | } |