History

kconfig: fix segv fault in menuconfig

With specific configurations requesting help for certain menu lines caused menuconfig to crash. This was tracked down to a null pointer bug. Thanks to "Miles Lane" <miles.lane@gmail.com> for inital reporting and to Gabriel C <nix.or.die@googlemail.com> for the backtrace that helped me locating the bug.

Sam Ravnborg committed 19 years ago

Commit a67cb131 parent 48874072 files · +11 −7Browse files

Showing the changes to scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. scripts/kconfig/mconf.c +3 −2
  2. scripts/kconfig/util.c +8 −5
scripts/kconfig/mconf.c+3−2
@@ -357,8 +357,9 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym) · 356 unmodified lines
357357 bool hit;
358358 struct property *prop;
359359
360− str_printf(r, "Symbol: %s [=%s]\n", sym->name,
361− sym_get_string_value(sym));
360+ if (sym && sym->name)
361+ str_printf(r, "Symbol: %s [=%s]\n", sym->name,
362+ sym_get_string_value(sym));
362363 for_all_prompts(sym, prop)
363364 get_prompt_str(r, prop);
364365 hit = false;
scripts/kconfig/util.c+8−5
@@ -84,12 +84,15 @@ void str_free(struct gstr *gs) · 83 unmodified lines
8484 /* Append to growable string */
8585 void str_append(struct gstr *gs, const char *s)
8686 {
87− size_t l = strlen(gs->s) + strlen(s) + 1;
88− if (l > gs->len) {
89− gs->s = realloc(gs->s, l);
90− gs->len = l;
87+ size_t l;
88+ if (s) {
89+ l = strlen(gs->s) + strlen(s) + 1;
90+ if (l > gs->len) {
91+ gs->s = realloc(gs->s, l);
92+ gs->len = l;
93+ }
94+ strcat(gs->s, s);
9195 }
92− strcat(gs->s, s);
9396 }
9497
9598 /* Append printf formatted string to growable string */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t