summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHartmut Brandt <harti@FreeBSD.org>2006-02-07 15:48:37 +0000
committerHartmut Brandt <harti@FreeBSD.org>2006-02-07 15:48:37 +0000
commit74b07c5412065adfab90021f6ded2bdf7304744d (patch)
tree6507fb8b47a87f2e244042055c893a5ca8b7273c
parent860ae58e3f6189778c16c6f5c975b47e338be71c (diff)
parentfa122c203805f13e7cef78610f1dd167671cd93e (diff)
downloadsrc-test2-74b07c5412065adfab90021f6ded2bdf7304744d.tar.gz
src-test2-74b07c5412065adfab90021f6ded2bdf7304744d.zip
Notes
-rw-r--r--contrib/bsnmp/snmpd/export.c24
-rw-r--r--contrib/bsnmp/snmpd/snmpmod.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/contrib/bsnmp/snmpd/export.c b/contrib/bsnmp/snmpd/export.c
index b4cb9a802268..52205e7f11cb 100644
--- a/contrib/bsnmp/snmpd/export.c
+++ b/contrib/bsnmp/snmpd/export.c
@@ -121,6 +121,30 @@ string_get(struct snmp_value *value, const u_char *ptr, ssize_t len)
}
/*
+ * Get a string value for a response packet but cut it if it is too long.
+ */
+int
+string_get_max(struct snmp_value *value, const u_char *ptr, ssize_t len,
+ size_t maxlen)
+{
+
+ if (ptr == NULL) {
+ value->v.octetstring.len = 0;
+ value->v.octetstring.octets = NULL;
+ return (SNMP_ERR_NOERROR);
+ }
+ if (len == -1)
+ len = strlen(ptr);
+ if ((size_t)len > maxlen)
+ len = maxlen;
+ value->v.octetstring.len = (u_long)len;
+ if ((value->v.octetstring.octets = malloc((size_t)len)) == NULL)
+ return (SNMP_ERR_RES_UNAVAIL);
+ memcpy(value->v.octetstring.octets, ptr, (size_t)len);
+ return (SNMP_ERR_NOERROR);
+}
+
+/*
* Support for IPADDRESS
*
* Save the old IP address in scratch->int1 and set the new one.
diff --git a/contrib/bsnmp/snmpd/snmpmod.h b/contrib/bsnmp/snmpd/snmpmod.h
index 4ce502ca5b44..18457bfc5b1b 100644
--- a/contrib/bsnmp/snmpd/snmpmod.h
+++ b/contrib/bsnmp/snmpd/snmpmod.h
@@ -400,6 +400,7 @@ int string_save(struct snmp_value *, struct snmp_context *, ssize_t, u_char **);
void string_commit(struct snmp_context *);
void string_rollback(struct snmp_context *, u_char **);
int string_get(struct snmp_value *, const u_char *, ssize_t);
+int string_get_max(struct snmp_value *, const u_char *, ssize_t, size_t);
void string_free(struct snmp_context *);
int ip_save(struct snmp_value *, struct snmp_context *, u_char *);