summaryrefslogtreecommitdiff
path: root/getgbook.c
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2011-08-21 17:00:00 +0100
committerNick White <git@njw.me.uk>2011-08-21 17:00:00 +0100
commitbe77fe85042dfcc4a943c4c979ba7b990d6a124f (patch)
treeed709eb7d57e9e694d4cc53a04abb97a96d8d5a5 /getgbook.c
parentb686e031da6622b329d43c361b196eda46ea5154 (diff)
Tighten sscanf usage, add TODOs
Diffstat (limited to 'getgbook.c')
-rw-r--r--getgbook.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/getgbook.c b/getgbook.c
index 5f1e381..62faf46 100644
--- a/getgbook.c
+++ b/getgbook.c
@@ -23,7 +23,7 @@ typedef struct {
int getpagelist(char *bookid, Page **pages)
{
- char url[URLMAX];
+ char url[URLMAX], m[STRMAX];
char *buf;
char *s;
int i;
@@ -43,7 +43,8 @@ int getpagelist(char *bookid, Page **pages)
if(*s == ']')
break;
if(!strncmp(s, "\"pid\"", 5)) {
- sscanf(s+6, "\"%[^\"]\",", p->name);
+ snprintf(m, STRMAX, "\"%%%d[^\"]\"", STRMAX-1);
+ sscanf(s+6, m, p->name);
for(;*s; s++) {
if(*s == '}')
break;
@@ -58,7 +59,7 @@ int getpagelist(char *bookid, Page **pages)
}
int getpageurls(char *bookid, Page **pages, int totalpages, char *pagecode, char *cookie) {
- char url[URLMAX], code[STRMAX];
+ char url[URLMAX], code[STRMAX], m[STRMAX];
char *c, *d, *p, *buf = NULL;
int i;
@@ -69,7 +70,8 @@ int getpageurls(char *bookid, Page **pages, int totalpages, char *pagecode, char
c = buf;
while(*c && (c = strstr(c, "\"pid\":"))) {
- if(!sscanf(c, "\"pid\":\"%[^\"]\"", code))
+ snprintf(m, STRMAX, "\"pid\":\"%%%d[^\"]\"", STRMAX-1);
+ if(!sscanf(c, m, code))
break;
for(; *c; c++) {
if(*c == '}') {