summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jones <daniel@danieljon.es>2019-03-06 23:38:35 -0500
committerDaniel Jones <daniel@danieljon.es>2019-03-06 23:38:35 -0500
commit62008cec2f1e4002a41ce0ad37449e64abb9b10e (patch)
tree719e0e5b20f46630c0a13745e5b7a66eceb54c0b
parent08865618d2a8103e022b6b7dcc0e4f9f6d4be182 (diff)
downloadurlopener-62008cec2f1e4002a41ce0ad37449e64abb9b10e.tar.gz
urlopener-62008cec2f1e4002a41ce0ad37449e64abb9b10e.zip
some comments and error handling
-rw-r--r--urlopen.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/urlopen.c b/urlopen.c
index dbe1223..e68f272 100644
--- a/urlopen.c
+++ b/urlopen.c
@@ -38,7 +38,7 @@ char *programs[][2] =
char *forceddomains[][2] =
{
- /* if the odmain is listed here, the index into programs[][]
+ /* if the domain is listed here, the index into programs[x][]
* will be the number, don't add the protocol identifier
*/
{"youtube.com", "2"},
@@ -58,8 +58,9 @@ islink(char *url)
{
int s = (p-url);
/*
- * check if the number of characters before the '://' is >0 && <5 && contains a '.'
- * 10 is a guess, i have no idea what the limit of a protocol identifier is
+ * check if the number of characters before the '://' is >0 && <10 && contains a '.'
+ * 10 is a reasonable number plucked out of thin air, RFC 3986 does not state a maximum
+ * we would like to avoid false positives, not that it matters much
*/
if (s > 0 && s <= 10 && strchr(url, '.') != NULL)
// it's probably a link
@@ -111,13 +112,16 @@ checkforceddomains(char *url, int ext)
* checking process:
* domain is already probably a url
* check if first x characters after protocol identifier is in the list?
- * return the number in specified
+ * return the number specified in the array
*/
int ret = ext;
char *buff = malloc(BUFFSIZE);
char *buff2 = malloc(BUFFSIZE);
if (buff == NULL || buff2 == NULL)
+ {
+ perror("malloc");
goto exitdomaincheck; /* exit right away */
+ }
strncpy(buff, url, BUFFSIZE-1);
char *p = NULL;
p = strstr(buff, "://");