modpost: fix segfault with short symbol names
authorMichal Marek <mmarek@suse.cz>
Sat, 12 Dec 2009 11:02:24 +0000 (12:02 +0100)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 15 Dec 2009 05:58:37 +0000 (16:28 +1030)
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>
scripts/mod/modpost.c

index c16c0a0e2464002268f0db0db1ed3c051a55d2d8..6c4ffc767b91a16bfdc1e1aef9885bee66be3736 100644 (file)
@@ -522,7 +522,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
                break;
        case SHN_ABS:
                /* CRC'd symbol */
-               if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
+               if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
                        crc = (unsigned int) sym->st_value;
                        sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
                                        export);
@@ -566,7 +566,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
                break;
        default:
                /* All exported symbols */
-               if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
+               if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
                        sym_add_exported(symname + strlen(KSYMTAB_PFX), mod,
                                        export);
                }