commit 3c19febb014ddc7d9afa1b517c108da4b3fda5dc from: Omar Polo date: Fri Nov 06 13:24:25 2020 UTC ensure the requested protocol is “gemini” …and not something else that happens to be 6-bytes long. commit - e8cac16e03c5b86eebd6e50b267a3f0479bf3a81 commit + 3c19febb014ddc7d9afa1b517c108da4b3fda5dc blob - d54dc62f3b6ccded34abc27df946988df324e38c blob + 2f786bce62e15bbbebfdde9ea693ba0ef1964fd0 --- ChangeLog +++ ChangeLog @@ -1,3 +1,8 @@ +2020-11-06 Omar Polo + + * gmid.c (url_after_proto): ensure that the requested protocol is + “gemini” and not something else that’s long 6 bytes. + 2020-11-06 Omar Polo * gmid.1: added option to log to a file blob - cda5b72ba0095337cbedd0d7bbeac93cbb45f206 blob + c8348a0fa50bb6a6a3c9f05881989b5b30c17cf5 --- gmid.c +++ gmid.c @@ -141,17 +141,18 @@ url_after_proto(char *url) char *s; const char *proto = "gemini"; const char *marker = "://"; + size_t i; + /* a relative URL */ if ((s = strstr(url, marker)) == NULL) return url; - /* not a gemini:// URL */ - - if (s - strlen(proto) < url) + if (s - strlen(proto) != url) return NULL; - /* TODO: */ - /* if (strcmp(s - strlen(proto), proto)) */ - /* return NULL; */ + + for (i = 0; proto[i] != '\0'; ++i) + if (url[i] != proto[i]) + return NULL; /* a valid gemini:// URL */ return s + strlen(marker);