diff options
author | Sebastian Geerken <devnull@localhost> | 2016-01-27 07:59:08 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2016-01-27 07:59:08 +0100 |
commit | 382392aad21b6ade257e813aa836457d94af1b8f (patch) | |
tree | 126ce2950db4105027b246da964b3c06ffb5ab72 | |
parent | 138c244e93d19eddb2d385fcdf27b9cb1cd8f525 (diff) | |
parent | 87d1f3f2764a10c48ab30f1d602ef38197587623 (diff) |
Merge with hg.dillo.org.
-rw-r--r-- | dpi/bookmarks.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c index 32dc424f..f0467a8b 100644 --- a/dpi/bookmarks.c +++ b/dpi/bookmarks.c @@ -740,11 +740,20 @@ static int Bms_load(void) if (buf[0] == 's') { /* get section, url and title */ section = strtol(buf + 1, NULL, 10); - p = strchr(buf, ' '); *p = 0; + p = strchr(buf, ' '); + if (!p) + goto error; + *p = 0; url = ++p; - p = strchr(p, ' '); *p = 0; + p = strchr(p, ' '); + if (!p) + goto error; + *p = 0; title = ++p; - p = strchr(p, '\n'); *p = 0; + p = strchr(p, '\n'); + if (!p) + goto error; + *p = 0; u_title = Unescape_html_str(title); Bms_add(section, url, u_title); dFree(u_title); @@ -752,13 +761,22 @@ static int Bms_load(void) } else if (buf[0] == ':' && buf[1] == 's') { /* section = strtol(buf + 2, NULL, 10); */ p = strchr(buf + 2, ' '); + if (!p) + goto error; title = ++p; p = strchr(p, '\n'); *p = 0; + if (!p) + goto error; Bms_sec_add(title); - } else { - MSG("Syntax error in bookmarks file:\n %s", buf); + goto error; } + + dFree(buf); + continue; + +error: + MSG("Syntax error in bookmarks file:\n %s", buf); dFree(buf); } fclose(BmTxt); |