Show quoted text> strnlen() not available in old FreeBSD versions, patch incomplete...
A bit better patch.
(buflen - 1) currently work, but it is not documented, that string
returned by sysctl(3) is null terminated and strnlen(3) is more robust -
it will work for not terminated strings.
--- Sysctl.xs.orig 2009-09-25 19:50:50.000000000 +0000
+++ Sysctl.xs 2011-09-09 06:16:50.000000000 +0000
@@ -42,8 +42,10 @@
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
-
#include <netinet6/raw_ip6.h>
+
+#include <string.h>
+
#include "bsd-sysctl.h"
int
@@ -393,7 +395,11 @@
switch(oid_fmt) {
case FMT_A:
SvPOK_on(sv_buf);
- SvCUR_set(sv_buf, buflen);
+#if __FreeBSD_version < 800067
+ SvCUR_set(sv_buf, buflen - 1);
+#else
+ SvCUR_set(sv_buf, strnlen(buf, buflen));
+#endif
RETVAL = sv_buf;
break;
case FMT_INT: