summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2012-07-13 18:53:45 +0100
committerNick White <git@njw.me.uk>2012-07-13 18:53:45 +0100
commit995154b47f4965e8036d90a4a918dd9ba4921503 (patch)
tree5439eedd7425848058b54d1507dc00a8a7b11a11
parent51c41296bca9e06cfa2d53ce3a0837e1a8697b1c (diff)
Don't allow download of bogus flash pages with getbnbook
-rw-r--r--getbnbook.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/getbnbook.c b/getbnbook.c
index dba1856..a9ae88d 100644
--- a/getbnbook.c
+++ b/getbnbook.c
@@ -69,6 +69,21 @@ int getpagelist()
return 0;
}
+int isflash(char *path)
+{
+ FILE *f;
+ int ret;
+
+ if((f = fopen(path, "rb")) == NULL)
+ return 1;
+
+ ret = fgetc(f) == 'F' ? 1 : 0;
+
+ fclose(f);
+
+ return ret;
+}
+
int getpage(int pagenum)
{
char path[STRMAX], pageurl[STRMAX];
@@ -83,6 +98,11 @@ int getpage(int pagenum)
fprintf(stderr, "%d failed\n", pagenum);
return 1;
}
+ if(isflash(path)) {
+ fprintf(stderr, "%d not found\n", pagenum);
+ remove(path);
+ return 1;
+ }
renameifjpg(path);
printf("%d downloaded\n", pagenum);