Commit 21bb8527 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

Pavel Orehov reported memory problems with the multi interface in bug report

#1098843. In short, a shared DNS cache was setup for a multi handle and when
the shared cache was deleted before the individual easy handles, the latter
cleanups caused read/writes to already freed memory.
parent 83bab78b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -8,6 +8,11 @@


Daniel (10 January 2005)
- Pavel Orehov reported memory problems with the multi interface in bug report
  #1098843. In short, a shared DNS cache was setup for a multi handle and when
  the shared cache was deleted before the individual easy handles, the latter
  cleanups caused read/writes to already freed memory.

- Hzhijun reported a memory leak in the SSL certificate code, that leaked the
  remote certificate name when it didn't match the used host name.

+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ This release includes the following changes:

This release includes the following bugfixes:

 o memory problem with cleaning up multi interface
 o SSL certificate name memory leak
 o -d with -G to multiple URLs crashed
 o double va_list access crash fixed
@@ -33,6 +34,6 @@ advice from friends like these:

 Dan Fandrich, Peter Pentchev, Marcin Konicki, Rune Kleveland, David Shaw,
 Werner Koch, Gisle Vanem, Alex Neblett, Kai Sommerfeld, Marty Kuhrt,
 Hzhijun
 Hzhijun, Pavel Orehov

        Thanks! (and sorry if I forgot to mention someone)
+10 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@
#include "share.h"
#include "memory.h"
#include "progress.h"
#include "easy.h"

#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -403,6 +404,15 @@ void curl_easy_cleanup(CURL *curl)
  Curl_close(data);
}

/*
 * Store a pointed to the multi handle within the easy handle's data struct.
 */
void Curl_easy_addmulti(struct SessionHandle *data,
                        void *multi)
{
  data->multi = multi;
}

/*
 * curl_easy_getinfo() is an external interface that allows an app to retrieve
 * information from a performed transfer and similar.

lib/easy.h

0 → 100644
+31 −0
Original line number Diff line number Diff line
#ifndef __EASY_H
#define __EASY_H
/***************************************************************************
 *                                  _   _ ____  _
 *  Project                     ___| | | |  _ \| |
 *                             / __| | | | |_) | |
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * are also available at http://curl.haxx.se/docs/copyright.html.
 *
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
 * copies of the Software, and permit persons to whom the Software is
 * furnished to do so, under the terms of the COPYING file.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 * $Id$
 ***************************************************************************/

/*
 * Prototypes for library-wide functions provided by easy.c
 */
void Curl_easy_addmulti(struct SessionHandle *data, void *multi);

#endif /* __EASY_H */
+11 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "connect.h"
#include "progress.h"
#include "memory.h"
#include "easy.h"

/* The last #include file should be: */
#include "memdebug.h"
@@ -174,6 +175,8 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
  if(easy->next)
    easy->next->prev = easy;

  Curl_easy_addmulti(easy_handle, multi_handle);

  /* increase the node-counter */
  multi->num_easy++;

@@ -584,6 +587,13 @@ CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles)
  return result;
}

/* This is called when an easy handle is cleanup'ed that is part of a multi
   handle */
void Curl_multi_rmeasy(void *multi_handle, CURL *easy_handle)
{
  curl_multi_remove_handle(multi_handle, easy_handle);
}

CURLMcode curl_multi_cleanup(CURLM *multi_handle)
{
  struct Curl_multi *multi=(struct Curl_multi *)multi_handle;
@@ -600,6 +610,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
      nexteasy=easy->next;
      /* clear out the usage of the shared DNS cache */
      easy->easy_handle->hostcache = NULL;
      easy->easy_handle->multi = NULL;

      if (easy->msg)
        free(easy->msg);
Loading