commit 3a3fab296da4c9ccf215db397e56f643a39e9944 from: Martijn van Duren date: Sun Mar 20 15:44:37 2022 UTC Fix osmtpd_mheader_skip_hyphenatedword: Don't return a NULL-pointer if content is valid commit - f15094901545c7a69c0989c80bc8715829c34db4 commit + 3a3fab296da4c9ccf215db397e56f643a39e9944 blob - a673215a42df4f74a3c93a4b16ba0b6292a5f430 blob + e57f15bdb8c8c4014114be0ac5b8eb26391c82e3 --- mheader.c +++ mheader.c @@ -763,16 +763,15 @@ osmtpd_mheader_skip_base64string(char *ptr, int option char * osmtpd_mheader_skip_hyphenatedword(char *ptr, int optional) { - char *start = ptr, *prev; - int ishyp = 0; + char *start = ptr, *end, *hyphen; if ((ptr = osmtpd_mheader_skip_alpha(ptr, 0)) == NULL) return optional ? start : NULL; - prev = ptr; + end = ptr; while (1) { if (ptr[0] == '-') { - ishyp = 1; + hyphen = hyphen == NULL ? ptr - 1 : hyphen; ptr++; continue; } @@ -780,11 +779,11 @@ osmtpd_mheader_skip_hyphenatedword(char *ptr, int opti if ((ptr = osmtpd_mheader_skip_alpha(start, 0)) == NULL && (ptr = osmtpd_mheader_skip_digit(start, 0)) == NULL) break; - ishyp = 0; - prev = ptr; + hyphen = NULL; + end = ptr; } - return ishyp ? prev : ptr; + return hyphen == NULL ? end : hyphen; } char *