X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fmono-route.c;h=c90af3cdfe33b8b89d1ce23f65a14e42046ff636;hb=HEAD;hp=5f3ecb93ea65582aaadb6081e7cfa9e1f2f0c7dc;hpb=4c960e1dd530396fdd9400c87729a6ce3101e5c1;p=mono.git diff --git a/mono/metadata/mono-route.c b/mono/metadata/mono-route.c index 5f3ecb93ea6..c90af3cdfe3 100644 --- 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) */ -#if defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD) +#include +#if defined(HOST_DARWIN) || defined(HOST_BSD) #include #include #include @@ -57,8 +59,10 @@ extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope 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; + } 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++; } - *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; @@ -98,12 +104,15 @@ extern MonoBoolean ves_icall_System_Net_NetworkInformation_MacOsIPInterfacePrope // 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++; } +leave: g_free (buf); - return TRUE; + return is_ok (&error); } 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; } -#endif /* #if defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD) */ +#endif /* #if defined(HOST_DARWIN) || defined(HOST_BSD) */