clamd: scanstream: add mutex around gethostbyname

git-svn: trunk@711
remotes/push_mirror/metadata
Tomasz Kojm 21 years ago
parent d4fb658ee3
commit d9855a9547
  1. 4
      clamav-devel/ChangeLog
  2. 8
      clamav-devel/clamd/scanner.c

@ -1,3 +1,7 @@
Fri Jul 30 19:47:11 CEST 2004 (tk)
----------------------------------
* clamd: scanstream: add mutex around gethostbyname
Fri Jul 30 19:10:44 CEST 2004 (tk)
----------------------------------
* libclamav: cli_bm_free: free b-m nodes (patch by Igor Brezac

@ -34,6 +34,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include <clamav.h>
#include <pthread.h>
#include "cfgparser.h"
#include "others.h"
@ -49,6 +50,8 @@
dev_t procdev; /* /proc device */
#endif
pthread_mutex_t gh_mutex = PTHREAD_MUTEX_INITIALIZER;
int checksymlink(const char *path)
{
struct stat statbuf;
@ -239,11 +242,14 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root
server.sin_port = htons(port);
if((cpt = cfgopt(copt, "TCPAddr"))) {
if ((he = gethostbyname(cpt->strarg)) == 0) {
pthread_mutex_lock(&gh_mutex);
if((he = gethostbyname(cpt->strarg)) == 0) {
logg("!gethostbyname(%s) error: %s\n", cpt->strarg);
mdprintf(odesc, "gethostbyname(%s) ERROR\n", cpt->strarg);
pthread_mutex_unlock(&gh_mutex);
return -1;
}
pthread_mutex_unlock(&gh_mutex);
server.sin_addr = *(struct in_addr *) he->h_addr_list[0];
} else
server.sin_addr.s_addr = INADDR_ANY;

Loading…
Cancel
Save