commit 245a86c365a3d921a0ac2157809060c52925d619 from: Omar Polo date: Sat Dec 24 19:11:54 2022 UTC iri: avoid unpleasant infinite loop in remove_dot_segments need to copy until the *next* path segment, otherwise we loop indefinitely if *p == '/'. commit - f5bc8482f4f41abd20e767dd613fc323713f3820 commit + 245a86c365a3d921a0ac2157809060c52925d619 blob - 152a34c6023838c2691b4cd1052849df3caeeccb blob + c519730b00527490ead2d9c69c73074293ad25df --- iri.c +++ iri.c @@ -472,7 +472,7 @@ cpfields(struct iri *dest, const struct iri *src, int static inline int remove_dot_segments(struct iri *iri) { - char *p, *q, *buf; + char *p, *q, *buf, *s; ptrdiff_t bufsize; buf = p = q = iri->iri_path; @@ -516,7 +516,8 @@ remove_dot_segments(struct iri *iri) break; } /* E */ - while (*p && *p != '/' && (q - buf < bufsize)) + s = strchr(p + 1, '/'); + while (*p && p != s && (q - buf < bufsize)) *q++ = *p++; }