Hi All, I've attached a patch for potential inclusion into curl. The patch modifies how slist_append handles the situation where a NULL char* is passed in, currently this causes a segfault. While I agree people shouldn't be passing a NULL value in I have fixed that issue in the app I discovered this in so it can't happen I do think that modifying curl so it doesn't segfault would be an improvement.
The way I have chosen to fix this in curl is to allow append to return the original list is the data to be added is NULL, this both prevents a segfault and also prevents data loss(and potential memory leak) that would be caused by returning NULL. Any comments on validity/changes welcome. I have also attached a patch that updates the man page in the event the first patch is included and a mini c app that replicates the segfault on current curl builds and demonstrates the fix functions correctly on inclusion. Cheers, Rob -- ------------------------------ Rob Ward www.rob-ward.co.uk
#include <curl/curl.h>
int main(void)
{
struct curl_slist *slist = NULL;
struct curl_slist *it = NULL;
char* alpha = "alpha";
char* beta = "beta";
char* gamma = NULL;
char* omega = "omega";
fprintf(stderr, "\nAbout to add alpha");
slist = curl_slist_append(slist, alpha);
fprintf(stderr, "\nAbout to add beta");
slist = curl_slist_append(slist, beta);
fprintf(stderr, "\nAbout to add gamma - NULL");
slist = curl_slist_append(slist, gamma);
fprintf(stderr, "\nAbout to add omega");
slist = curl_slist_append(slist, omega);
fprintf(stderr,"\n");
it = slist;
while(it) {
fprintf(stderr, "\nlist element = |%s|", it->data);
it = it->next;
}
curl_slist_free_all(slist); /* free the list again */
fprintf(stderr,"\n");
return 0;
}
0001-Modify-slist_append-to-stop-failure-on-NULL-data.patch
Description: Binary data
0002-Modified-curl_list_append-man-page.patch
Description: Binary data
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
