commit b38e9a2a1732c7dd3d16d76facf977f5a4c4a454 from: Omar Polo via: Thomas Adam date: Wed Nov 22 22:46:45 2023 UTC gotwebd: improve gotwebd_assign_querystring() This prevents the issues that we just hit with forgetting to remove PREVID: instead of relying on the enum value to yield the size of a table, use nitems(). Also, quit as soon as the matching key was found, no need to iterate further. ok stsp@ commit - 14b59d10858a4042d92f9ec960c38c34fd7e39a6 commit + b38e9a2a1732c7dd3d16d76facf977f5a4c4a454 blob - 7cfd0bb7c8b86231b15609ba3157f2edf4ad6c5f blob + 57847f9088185127ba71f00e741f8b5daae32cad --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -558,7 +558,7 @@ gotweb_assign_querystring(struct querystring **qs, cha if (error) return error; - for (el_cnt = 0; el_cnt < QSELEM__MAX; el_cnt++) { + for (el_cnt = 0; el_cnt < nitems(querystring_keys); el_cnt++) { if (strcmp(key, querystring_keys[el_cnt].name) != 0) continue; @@ -644,9 +644,10 @@ qa_found: if ((*qs)->page < 0) (*qs)->page = 0; break; - default: - break; } + + /* entry found */ + break; } done: return error; blob - 09f798e6fb6a8b4072211ee13052ba126de871c0 blob + 8f6bd6f3682bf436854e307fec5f3f9ed867d144 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -418,7 +418,6 @@ enum querystring_elements { INDEX_PAGE, PATH, PAGE, - QSELEM__MAX, }; enum query_actions {