summaryrefslogtreecommitdiff
path: root/lib/libagentx/ax.c
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2020-10-27 17:19:45 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2020-10-27 17:19:45 +0000
commite56426a041ae3dc1d80e2eb94fcf57a74f90f73c (patch)
tree43a69a7262722931f2d31e88ac451725b3f6b097 /lib/libagentx/ax.c
parent99576385a759740bfa4c8f2f8d58ef2e6c5fe7cd (diff)
According to SMI (RFC 2578) an integer is signed. Somehow I managed to
overlook this. This change prevens indices larger then INT32_MAX, but this shouldn't happen in the current code (relayd) anyway. In all other cases the bytes would've been passed on to SNMP anyway, so there's no effective difference there. Probably no ABI-change, but we can ride yesterday's bump anyway. OK tb@
Diffstat (limited to 'lib/libagentx/ax.c')
-rw-r--r--lib/libagentx/ax.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/libagentx/ax.c b/lib/libagentx/ax.c
index 309c756f23b..66a4240ecb8 100644
--- a/lib/libagentx/ax.c
+++ b/lib/libagentx/ax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ax.c,v 1.3 2020/10/26 19:02:30 martijn Exp $ */
+/* $OpenBSD: ax.c,v 1.4 2020/10/27 17:19:44 martijn Exp $ */
/*
* Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org>
*
@@ -792,8 +792,8 @@ ax_varbind2string(struct ax_varbind *vb)
switch (vb->avb_type) {
case AX_DATA_TYPE_INTEGER:
- snprintf(buf, sizeof(buf), "%s: (int)%u",
- ax_oid2string(&(vb->avb_oid)), vb->avb_data.avb_uint32);
+ snprintf(buf, sizeof(buf), "%s: (int)%d",
+ ax_oid2string(&(vb->avb_oid)), vb->avb_data.avb_int32);
break;
case AX_DATA_TYPE_OCTETSTRING:
for (i = 0;
@@ -1161,6 +1161,10 @@ ax_pdu_add_varbindlist(struct ax *ax,
return -1;
switch (vblist[i].avb_type) {
case AX_DATA_TYPE_INTEGER:
+ if (ax_pdu_add_uint32(ax,
+ vblist[i].avb_data.avb_int32) == -1)
+ return -1;
+ break;
case AX_DATA_TYPE_COUNTER32:
case AX_DATA_TYPE_GAUGE32:
case AX_DATA_TYPE_TIMETICKS:
@@ -1321,6 +1325,10 @@ ax_pdutovarbind(struct ax_pdu_header *header,
switch(varbind->avb_type) {
case AX_DATA_TYPE_INTEGER:
+ if (rawlen < 4)
+ goto fail;
+ varbind->avb_data.avb_int32 = ax_pdutoh32(header, buf);
+ return rread + 4;
case AX_DATA_TYPE_COUNTER32:
case AX_DATA_TYPE_GAUGE32:
case AX_DATA_TYPE_TIMETICKS: