projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #5714 from alexischr/update_bockbuild
[mono.git]
/
mono
/
metadata
/
mono-route.c
diff --git
a/mono/metadata/mono-route.c
b/mono/metadata/mono-route.c
index 5f3ecb93ea65582aaadb6081e7cfa9e1f2f0c7dc..c90af3cdfe33b8b89d1ce23f65a14e42046ff636 100644
(file)
--- a/
mono/metadata/mono-route.c
+++ b/
mono/metadata/mono-route.c
@@
-1,13
+1,15
@@
-/*
- * mono-route.c: Read the network routing tables using sysctl(3) calls
- * Required for Unix-like systems that don't have Linux's /proc/net/route
+/**
+ * \file
+ * Read the network routing tables using sysctl(3) calls
+ * Required for Unix-like systems that don't have Linux's /proc/net/route
*
* Author:
* Ben Woods (woodsb02@gmail.com)
*/
*
* Author:
* Ben Woods (woodsb02@gmail.com)
*/
-#i
f defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD)
+#i
nclude <config.h>
+#if defined(HOST_DARWIN) || defined(HOST_BSD)
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
@@
-57,8
+59,10
@@
extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope
return FALSE;
// Second sysctl call to retrieve data into appropriately sized buffer
return FALSE;
// Second sysctl call to retrieve data into appropriately sized buffer
- if (sysctl(mib, G_N_ELEMENTS(mib), buf, &needed, NULL, 0) < 0)
+ if (sysctl(mib, G_N_ELEMENTS(mib), buf, &needed, NULL, 0) < 0) {
+ g_free (buf);
return FALSE;
return FALSE;
+ }
lim = buf + needed;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
lim = buf + needed;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
@@
-72,7
+76,9
@@
extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope
num_gws++;
}
num_gws++;
}
- *gw_addr_list = mono_array_new(domain, mono_get_string_class (), num_gws);
+ *gw_addr_list = mono_array_new_checked (domain, mono_get_string_class (), num_gws, &error);
+ if (!is_ok (&error))
+ goto leave;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
for (next = buf; next < lim; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)next;
@@
-98,12
+104,15
@@
extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope
// snprintf output truncated
continue;
// snprintf output truncated
continue;
- addr_string = mono_string_new (domain, addr);
+ addr_string = mono_string_new_checked (domain, addr, &error);
+ if (!is_ok (&error))
+ goto leave;
mono_array_setref (*gw_addr_list, gwnum, addr_string);
gwnum++;
}
mono_array_setref (*gw_addr_list, gwnum, addr_string);
gwnum++;
}
+leave:
g_free (buf);
g_free (buf);
- return
TRUE
;
+ return
is_ok (&error)
;
}
in_addr_t gateway_from_rtm(struct rt_msghdr *rtm)
}
in_addr_t gateway_from_rtm(struct rt_msghdr *rtm)
@@
-125,4
+134,4
@@
in_addr_t gateway_from_rtm(struct rt_msghdr *rtm)
return 0;
}
return 0;
}
-#endif /* #if defined(
PLATFORM_MACOSX) || defined(PLATFORM
_BSD) */
+#endif /* #if defined(
HOST_DARWIN) || defined(HOST
_BSD) */