diff -ur /home/cupotka/radiusclient/lib//avpair.c radiusclient/lib//avpair.c
--- /home/cupotka/radiusclient/lib//avpair.c	2010-02-04 12:30:26.000000000 +0200
+++ radiusclient/lib//avpair.c	2010-03-02 13:32:25.000000000 +0200
@@ -564,7 +564,7 @@
 
 			    case PW_TYPE_DATE:
 				timeval = time (0);
-				tm = localtime (&timeval);
+				localtime_r (&timeval, tm);
 				tm->tm_hour = 0;
 				tm->tm_min = 0;
 				tm->tm_sec = 0;
@@ -649,8 +649,10 @@
 {
 	DICT_VALUE     *dval;
 	char            buffer[32];
+	char		ip[32];
 	struct in_addr  inad;
 	unsigned char         *ptr;
+	struct tm	*gmt;
 
 	*name = *value = '\0';
 
@@ -703,15 +705,17 @@
 		break;
 
 	    case PW_TYPE_IPADDR:
-		inad.s_addr = htonl(pair->lvalue);
-		strncpy (value, inet_ntoa (inad), (size_t) lv-1);
-		break;
+                inad.s_addr = htonl(pair->lvalue);
+                inet_ntop(AF_INET,&inad,ip,sizeof(ip));
+                strncpy (value, ip, (size_t) lv-1);
+                break;
+
 
 	    case PW_TYPE_DATE:
-		strftime (buffer, sizeof (buffer), "%m/%d/%y %H:%M:%S",
-			  gmtime ((time_t *) & pair->lvalue));
-		strncpy(value, buffer, lv-1);
-		break;
+                gmtime_r ((time_t *) & pair->lvalue, gmt);
+                strftime (buffer, sizeof (buffer), "%m/%d/%y %H:%M:%S", gmt);
+                strncpy(value, buffer, lv-1);
+                break;
 
 	    default:
 		rc_log(LOG_ERR, "rc_avpair_tostr: unknown attribute type %d", pair->type);
diff -ur /home/cupotka/radiusclient/lib//buildreq.c radiusclient/lib//buildreq.c
--- /home/cupotka/radiusclient/lib//buildreq.c	2010-02-04 12:27:09.000000000 +0200
+++ radiusclient/lib//buildreq.c	2010-03-02 17:23:06.115592979 +0200
@@ -44,8 +44,8 @@
 
 unsigned char rc_get_id()
 {
-	srandom((unsigned int)(time(NULL)+getpid()));
-	return (unsigned char)(random() & UCHAR_MAX);
+	static volatile unsigned char id=0;
+	return ++id;
 }
 
 /*
diff -ur /home/cupotka/radiusclient/lib//config.c radiusclient/lib//config.c
--- /home/cupotka/radiusclient/lib//config.c	2008-02-11 08:54:23.000000000 +0200
+++ radiusclient/lib//config.c	2010-03-02 14:06:08.000000000 +0200
@@ -94,7 +94,9 @@
 	char *p_save;
 	char *q;
 	char *s;
-	struct servent *svp;
+	struct servent servbuf, *svp;
+	char buffer[128];
+	int ret;
 
 	p_dupe = strdup(p);
 
@@ -141,12 +143,12 @@
 		serv->port[serv->max] = atoi(q);
 	} else {
 		if (!strcmp(option->name,"authserver"))
-			if ((svp = getservbyname ("radius", "udp")) == NULL)
+			if ((ret = getservbyname_r ("radius", "udp", &servbuf, buffer, sizeof(buffer), &svp)) != 0)
 				serv->port[serv->max] = PW_AUTH_UDP_PORT;
 			else
 				serv->port[serv->max] = ntohs ((unsigned int) svp->s_port);
 		else if (!strcmp(option->name, "acctserver"))
-			if ((svp = getservbyname ("radacct", "udp")) == NULL)
+			if ((ret = getservbyname_r ("radacct", "udp", &servbuf, buffer, sizeof(buffer), &svp)) != 0)
 				serv->port[serv->max] = PW_ACCT_UDP_PORT;
 			else
 				serv->port[serv->max] = ntohs ((unsigned int) svp->s_port);
diff -ur /home/cupotka/radiusclient/lib//ip_util.c radiusclient/lib//ip_util.c
--- /home/cupotka/radiusclient/lib//ip_util.c	2007-07-11 20:29:29.000000000 +0300
+++ radiusclient/lib//ip_util.c	2010-03-02 14:06:38.000000000 +0200
@@ -228,9 +228,11 @@
 
 unsigned short rc_getport(int type)
 {
-	struct servent *svp;
+	struct servent servbuf, *svp;
+	int ret;
+	char buffer[128];
 
-	if ((svp = getservbyname ((type==AUTH)?"radius":"radacct", "udp")) == NULL)
+	if ((ret = getservbyname_r ((type==AUTH)?"radius":"radacct", "udp", &servbuf, buffer, sizeof(buffer),&svp)) != 0)
 	{
 		return (type==AUTH) ? PW_AUTH_UDP_PORT : PW_ACCT_UDP_PORT;
 	} else {
diff -ur /home/cupotka/radiusclient/lib//sendserver.c radiusclient/lib//sendserver.c
--- /home/cupotka/radiusclient/lib//sendserver.c	2010-03-02 17:01:19.729103859 +0200
+++ radiusclient/lib//sendserver.c	2010-03-02 15:58:50.000000000 +0200
@@ -299,10 +299,6 @@
 		auth->length = htons ((unsigned short) total_length);
 	}
 
-	DEBUG(LOG_ERR, "DEBUG: local %s : 0, remote %s : %u\n", 
-		inet_ntoa(sinlocal.sin_addr),
-		inet_ntoa(sinremote.sin_addr), data->svc_port);
-
 	for (;;)
 	{
 		sendto (sockfd, (char *) auth, (unsigned int) total_length, (int) 0,
@@ -314,7 +310,7 @@
 		start_time = rc_getctime();
 		for (timeout = data->timeout; timeout > 0;
 		    timeout -= rc_getctime() - start_time) {
-			result = poll(&pfd, 1, timeout * 1000000);
+			result = poll(&pfd, 1, timeout * 1000);
 			if (result != -1 || errno != EINTR)
 				break;
 		}
@@ -335,8 +331,8 @@
 		if (++retries >= retry_max)
 		{
 			rc_log(LOG_ERR,
-				"rc_send_server: no reply from RADIUS server %s:%u, %s",
-				 rc_ip_hostname (auth_ipaddr), data->svc_port, inet_ntoa(sinremote.sin_addr));
+				"rc_send_server: no reply from RADIUS server %s:%u",
+				 rc_ip_hostname (auth_ipaddr), data->svc_port);
 			close (sockfd);
 			memset (secret, '\0', sizeof (secret));
 			return TIMEOUT_RC;
@@ -566,10 +562,10 @@
 		return;
 	} /* else fall through */
 #endif
-	srand ((unsigned)time (0) + getppid() + getpid()); /* random enough :) */
+	unsigned int seed=(unsigned)time (0) + getppid() + getpid(); /* random enough :) */
 	for (i = 0; i < AUTH_VECTOR_LEN;)
 	{
-		randno = rand ();
+		randno = rand_r (&seed);
 		memcpy ((char *) vector, (char *) &randno, sizeof (int));
 		vector += sizeof (int);
 		i += sizeof (int);
