[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r795 - in /fsf/trunk/libc: ChangeLog sunrpc/svc_run.c
- To: commits@xxxxxxxxxx
- Subject: [commits] r795 - in /fsf/trunk/libc: ChangeLog sunrpc/svc_run.c
- From: eglibc@xxxxxxxxxx
- Date: Tue, 28 Nov 2006 08:01:21 -0000
Author: eglibc
Date: Tue Nov 28 00:01:21 2006
New Revision: 795
Log:
Import glibc-mainline for 2006-11-28
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/sunrpc/svc_run.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Tue Nov 28 00:01:21 2006
@@ -1,3 +1,10 @@
+2006-11-27 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ [BZ #3559]
+ * sunrpc/svc_run.c (svc_run): Fail instead of segfaulting if
+ malloc crashed. Don't allocate memory unnecessarily in each
+ loop.
+
2006-10-21 Jakub Jelinek <jakub@xxxxxxxxxx>
* resolv/mapv4v6addr.h (map_v4v6_address): Fix last change.
Modified: fsf/trunk/libc/sunrpc/svc_run.c
==============================================================================
--- fsf/trunk/libc/sunrpc/svc_run.c (original)
+++ fsf/trunk/libc/sunrpc/svc_run.c Tue Nov 28 00:01:21 2006
@@ -51,36 +51,51 @@
svc_run (void)
{
int i;
+ struct pollfd *my_pollfd = NULL;
+ int last_max_pollfd = 0;
for (;;)
{
- struct pollfd *my_pollfd;
+ int max_pollfd = svc_max_pollfd;
+ if (max_pollfd == 0 && svc_pollfd == NULL)
+ break;
- if (svc_max_pollfd == 0 && svc_pollfd == NULL)
- return;
+ if (last_max_pollfd != max_pollfd)
+ {
+ struct pollfd *new_pollfd
+ = realloc (my_pollfd, sizeof (struct pollfd) * max_pollfd);
- my_pollfd = malloc (sizeof (struct pollfd) * svc_max_pollfd);
- for (i = 0; i < svc_max_pollfd; ++i)
+ if (new_pollfd == NULL)
+ {
+ perror (_("svc_run: - out of memory"));
+ break;
+ }
+
+ last_max_pollfd = max_pollfd;
+ }
+
+ for (i = 0; i < max_pollfd; ++i)
{
my_pollfd[i].fd = svc_pollfd[i].fd;
my_pollfd[i].events = svc_pollfd[i].events;
my_pollfd[i].revents = 0;
}
- switch (i = __poll (my_pollfd, svc_max_pollfd, -1))
+ switch (i = __poll (my_pollfd, max_pollfd, -1))
{
case -1:
- free (my_pollfd);
if (errno == EINTR)
continue;
perror (_("svc_run: - poll failed"));
- return;
+ break;
case 0:
- free (my_pollfd);
continue;
default:
INTUSE(svc_getreq_poll) (my_pollfd, i);
- free (my_pollfd);
+ continue;
}
+ break;
}
+
+ free (my_pollfd);
}