[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r105487: * src/process.c (Fnetwork_in
From: |
Andreas Schwab |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r105487: * src/process.c (Fnetwork_interface_list): Correctly determine buffer |
Date: |
Thu, 18 Aug 2011 17:33:22 +0200 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 105487
committer: Andreas Schwab <address@hidden>
branch nick: emacs
timestamp: Thu 2011-08-18 17:33:22 +0200
message:
* src/process.c (Fnetwork_interface_list): Correctly determine buffer
size.
modified:
src/ChangeLog
src/process.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2011-08-17 21:40:13 +0000
+++ b/src/ChangeLog 2011-08-18 15:33:22 +0000
@@ -1,3 +1,8 @@
+2011-08-18 Andreas Schwab <address@hidden>
+
+ * process.c (Fnetwork_interface_list): Correctly determine buffer
+ size.
+
2011-08-17 Chong Yidong <address@hidden>
* eval.c (internal_condition_case, internal_condition_case_1)
=== modified file 'src/process.c'
--- a/src/process.c 2011-08-14 17:51:08 +0000
+++ b/src/process.c 2011-08-18 15:33:22 +0000
@@ -3580,38 +3580,57 @@
if (s < 0)
return Qnil;
- again:
- buf_size *= 2;
- buf = xrealloc(buf, buf_size);
- if (!buf)
- {
- close (s);
- return Qnil;
- }
-
- ifconf.ifc_buf = buf;
- if (ioctl (s, SIOCGIFCONF, &ifconf))
- {
- close (s);
- xfree (buf);
- return Qnil;
- }
-
- if (ifconf.ifc_len == buf_size)
- goto again;
+ ifconf.ifc_buf = 0;
+ ifconf.ifc_len = 0;
+ if (ioctl (s, SIOCGIFCONF, &ifconf) == 0 && ifconf.ifc_len > 0)
+ {
+ ifconf.ifc_buf = xmalloc (ifconf.ifc_len);
+ if (ifconf.ifc_buf == NULL)
+ {
+ close (s);
+ return Qnil;
+ }
+ if (ioctl (s, SIOCGIFCONF, &ifconf))
+ {
+ close (s);
+ xfree (ifconf.ifc_buf);
+ return Qnil;
+ }
+ }
+ else
+ do
+ {
+ buf_size *= 2;
+ buf = xrealloc (buf, buf_size);
+ if (!buf)
+ {
+ close (s);
+ return Qnil;
+ }
+
+ ifconf.ifc_buf = buf;
+ ifconf.ifc_len = buf_size;
+ if (ioctl (s, SIOCGIFCONF, &ifconf))
+ {
+ close (s);
+ xfree (buf);
+ return Qnil;
+ }
+
+ }
+ while (ifconf.ifc_len == buf_size);
close (s);
res = Qnil;
- for (ifreq = ifconf.ifc_req;
- (char *) ifreq < (char *) (ifconf.ifc_req) + ifconf.ifc_len;
- )
+ ifreq = ifconf.ifc_req;
+ while ((char *) ifreq < (char *) ifconf.ifc_req + ifconf.ifc_len)
{
struct ifreq *ifq = ifreq;
#ifdef HAVE_STRUCT_IFREQ_IFR_ADDR_SA_LEN
-#define SIZEOF_IFREQ(sif) \
- ((sif)->ifr_addr.sa_len < sizeof(struct sockaddr) ? \
- sizeof((*sif)) : sizeof ((sif)->ifr_name) + sif->ifr_addr.sa_len)
+#define SIZEOF_IFREQ(sif) \
+ ((sif)->ifr_addr.sa_len < sizeof (struct sockaddr) \
+ ? sizeof (*(sif)) : sizeof ((sif)->ifr_name) + (sif)->ifr_addr.sa_len)
int len = SIZEOF_IFREQ (ifq);
#else
@@ -3619,7 +3638,7 @@
#endif
char namebuf[sizeof (ifq->ifr_name) + 1];
i += len;
- ifreq = (struct ifreq*) ((char*) ifreq + len);
+ ifreq = (struct ifreq *) ((char *) ifreq + len);
if (ifq->ifr_addr.sa_family != AF_INET)
continue;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r105487: * src/process.c (Fnetwork_interface_list): Correctly determine buffer,
Andreas Schwab <=