X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=list.c;h=fcafb5777b75da30055a7ff6795ea2424e7eba1d;hp=6f6b040dda26f2e1faa24b89620a029c324b5ecb;hb=e288372cb792160e0072de515859572cc370036a;hpb=0428133610c525457cb16f7ac6a54203a2743d6c diff --git a/list.c b/list.c index 6f6b040d..fcafb577 100644 --- a/list.c +++ b/list.c @@ -1,11 +1,9 @@ -const char list_rcs[] = "$Id: list.c,v 1.24 2011/04/19 13:00:47 fabiankeil Exp $"; +const char list_rcs[] = "$Id: list.c,v 1.28 2012/03/09 16:23:50 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/list.c,v $ * * Purpose : Declares functions to handle lists. - * Functions declared include: - * `destroy_list', `enlist' and `list_to_text' * * Copyright : Written by and Copyright (C) 2001-2007 the SourceForge * Privoxy team. http://www.privoxy.org/ @@ -353,7 +351,7 @@ jb_err enlist_unique(struct list *the_list, const char *str, { for (cur_entry = the_list->first; cur_entry != NULL; cur_entry = cur_entry->next) { - if ( (cur_entry->str != NULL) + if ((cur_entry->str != NULL) && (0 == strncmp(str, cur_entry->str, num_significant_chars))) { /* Already there */ @@ -366,7 +364,7 @@ jb_err enlist_unique(struct list *the_list, const char *str, /* Test whole string */ for (cur_entry = the_list->first; cur_entry != NULL; cur_entry = cur_entry->next) { - if ( (cur_entry->str != NULL) && (0 == strcmp(str, cur_entry->str))) + if ((cur_entry->str != NULL) && (0 == strcmp(str, cur_entry->str))) { /* Already there */ return JB_ERR_OK; @@ -417,8 +415,24 @@ jb_err enlist_unique_header(struct list *the_list, const char *name, if (NULL != header) { const size_t bytes_to_compare = strlen(name) + 2; + char *p = header; snprintf(header, header_size, "%s: %s", name, value); + /* + * The trailing "\r\n" is added by list_to_text(), + * if the caller passed them anyway, cut the header + * at the first one or dump core if this is a debug + * build. + */ + do + { + if ((*p == '\r') || (*p == '\n')) + { + assert(*p != '\r'); + assert(*p != '\n'); + *p = '\0'; + } + } while (*p++); result = enlist_unique(the_list, header, bytes_to_compare); free(header); assert(list_is_valid(the_list)); @@ -965,7 +979,7 @@ jb_err map(struct map *the_map, if ( (NULL == value) || (NULL == name) - || (NULL == (new_entry = zalloc(sizeof(*new_entry)))) ) + || (NULL == (new_entry = zalloc(sizeof(*new_entry))))) { if ((name != NULL) && (!name_needs_copying)) {