commit caad03081b5ab370b8e0aaee5795ff36fa6febd8 from: Omar Polo date: Wed Jan 27 15:05:50 2021 UTC some null checks commit - c4f682f8559b184d64b04aece37d3d2980859832 commit + caad03081b5ab370b8e0aaee5795ff36fa6febd8 blob - d0e5e4bd22f891050cb5a74b19f084005badb2db blob + 526d6c7dcb10507278f81fa92c85e9f519c896fa --- server.c +++ server.c @@ -35,7 +35,7 @@ vhost_lang(struct vhost *v, const char *path) struct location *loc; const char *lang = NULL; - if (v == NULL) + if (v == NULL || path == NULL) return lang; for (loc = v->locations; loc->match != NULL; ++loc) { @@ -53,6 +53,9 @@ vhost_default_mime(struct vhost *v, const char *path) { struct location *loc; const char *default_mime = "application/octet-stream"; + + if (v == NULL || path == NULL) + return default_mime; for (loc = v->locations; loc->match != NULL; ++loc) { if (!fnmatch(loc->match, path, 0)) { @@ -70,6 +73,9 @@ vhost_index(struct vhost *v, const char *path) struct location *loc; const char *index = "index.gmi"; + if (v == NULL || path == NULL) + return index; + for (loc = v->locations; loc->match != NULL; ++loc) { if (!fnmatch(loc->match, path, 0)) { if (loc->index != NULL)