diff --git a/kpatch-build/lookup.c b/kpatch-build/lookup.c index 9fa6c47..b88dc59 100644 --- a/kpatch-build/lookup.c +++ b/kpatch-build/lookup.c @@ -197,14 +197,22 @@ static void symtab_read(struct lookup_table *table, char *path) FILE *file; long unsigned int value, size; unsigned int i = 0; + int matched; char line[256], name[256], type[16], bind[16], ndx[16]; if ((file = fopen(path, "r")) == NULL) ERROR("fopen"); while (fgets(line, 256, file)) { - if (sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n", - &value, &size, type, bind, ndx, name) != 6 || + matched = sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n", + &value, &size, type, bind, ndx, name); + + if (matched == 5) { + name[0] = '\0'; + matched++; + } + + if (matched != 6 || !strcmp(ndx, "UNDEF") || !strcmp(type, "SECTION")) continue; @@ -220,8 +228,15 @@ static void symtab_read(struct lookup_table *table, char *path) rewind(file); while (fgets(line, 256, file)) { - if (sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n", - &value, &size, type, bind, ndx, name) != 6 || + matched = sscanf(line, "%*s %lx %lu %s %s %*s %s %s\n", + &value, &size, type, bind, ndx, name); + + if (matched == 5) { + name[0] = '\0'; + matched++; + } + + if (matched != 6 || !strcmp(ndx, "UNDEF") || !strcmp(type, "SECTION")) continue;