commit f141d2d1d0ceb8bda0ed3656141ec52c5c6e534f from: Omar Polo date: Fri Jun 14 10:44:57 2024 UTC mailcap: fix str_trim_whitespace return the pointer advanced past the leading blanks too. commit - 22d3f8e4de62efd76c31c5310120e36ffbdebb3d commit + f141d2d1d0ceb8bda0ed3656141ec52c5c6e534f blob - 05924ba1a8c77b65a263e80fcb8af97e7cbaca78 blob + 679c889ec81c97f40d2247149aac36ac37dde357 --- mailcap.c +++ mailcap.c @@ -46,7 +46,7 @@ static void str_append(char **, size_t *, char); static int str_getc(void); static char *str_tokenise(void); static int str_to_argv(char *, int *, char ***); -static void str_trim_whitespace(char *); +static char *str_trim_whitespace(char *); static void argv_free(int, char **); struct mailcaplist mailcaps = TAILQ_HEAD_INITIALIZER(mailcaps); @@ -74,7 +74,7 @@ enum mailcap_section { MAILCAP_END_OF_FIELDS, }; -static void +static char * str_trim_whitespace(char *s) { char *t; @@ -84,6 +84,7 @@ str_trim_whitespace(char *s) while (t >= s && isspace((unsigned char)*t)) *t-- = '\0'; + return s; } static void @@ -327,7 +328,7 @@ parse_mailcap_line(char *input) if ((line = strsep(&input, ";")) == NULL) break; - str_trim_whitespace(line); + line = str_trim_whitespace(line); switch (ms) { case MAILCAP_MIME: @@ -435,7 +436,7 @@ mailcap_parse(FILE *f) memset(&sps, 0, sizeof sps); copy = buf; - str_trim_whitespace(copy); + copy = str_trim_whitespace(copy); if (*copy == '#' || *copy == '\0') { free(buf); @@ -446,7 +447,7 @@ mailcap_parse(FILE *f) fprintf(stderr, "Error with entry: <<%s>>, line: %ld\n", copy, line); } - free(copy); + free(buf); } }