summaryrefslogtreecommitdiff
path: root/usr.sbin/snmpd
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2023-10-24 13:28:12 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2023-10-24 13:28:12 +0000
commit9aa0f6790cbfb1304fadd9ab58d6a1e398ceefaa (patch)
tree90f37987fc602eed223b7c8f29b0e911314d4a95 /usr.sbin/snmpd
parenteab399b544910d35d946debb3061295e80005445 (diff)
Always check if the context is available inside appl_agentx_recv().
Not every PDU goes through application.c. OK tb@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r--usr.sbin/snmpd/application.c4
-rw-r--r--usr.sbin/snmpd/application.h4
-rw-r--r--usr.sbin/snmpd/application_agentx.c8
3 files changed, 12 insertions, 4 deletions
diff --git a/usr.sbin/snmpd/application.c b/usr.sbin/snmpd/application.c
index dd92864786d..33bb8d7ceba 100644
--- a/usr.sbin/snmpd/application.c
+++ b/usr.sbin/snmpd/application.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: application.c,v 1.17 2022/12/20 20:04:55 martijn Exp $ */
+/* $OpenBSD: application.c,v 1.18 2023/10/24 13:28:11 martijn Exp $ */
/*
* Copyright (c) 2021 Martijn van Duren <martijn@openbsd.org>
@@ -175,7 +175,7 @@ appl_shutdown(void)
}
}
-static struct appl_context *
+struct appl_context *
appl_context(const char *name, int create)
{
struct appl_context *ctx;
diff --git a/usr.sbin/snmpd/application.h b/usr.sbin/snmpd/application.h
index 8b2c5678c3a..39e7b5fc410 100644
--- a/usr.sbin/snmpd/application.h
+++ b/usr.sbin/snmpd/application.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: application.h,v 1.5 2022/09/01 14:34:17 martijn Exp $ */
+/* $OpenBSD: application.h,v 1.6 2023/10/24 13:28:11 martijn Exp $ */
/*
* Copyright (c) 2021 Martijn van Duren <martijn@openbsd.org>
@@ -88,6 +88,7 @@ struct appl_varbind {
struct snmp_message;
enum snmp_version;
struct appl_backend;
+struct appl_context;
struct appl_backend_functions {
void (*ab_close)(struct appl_backend *, enum appl_close_reason);
@@ -121,6 +122,7 @@ struct appl_backend {
void appl(void);
void appl_init(void);
void appl_shutdown(void);
+struct appl_context *appl_context(const char *, int);
enum appl_error appl_register(const char *, uint32_t, uint8_t, struct ber_oid *,
int, int, uint8_t, uint32_t, struct appl_backend *);
enum appl_error appl_unregister(const char *, uint8_t, struct ber_oid *,
diff --git a/usr.sbin/snmpd/application_agentx.c b/usr.sbin/snmpd/application_agentx.c
index 3a67f9dc0f1..81b37bd9280 100644
--- a/usr.sbin/snmpd/application_agentx.c
+++ b/usr.sbin/snmpd/application_agentx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: application_agentx.c,v 1.7 2023/10/24 12:57:40 martijn Exp $ */
+/* $OpenBSD: application_agentx.c,v 1.8 2023/10/24 13:28:11 martijn Exp $ */
/*
* Copyright (c) 2022 Martijn van Duren <martijn@openbsd.org>
*
@@ -370,6 +370,12 @@ appl_agentx_recv(int fd, short event, void *cookie)
error = APPL_ERROR_PARSEERROR;
goto fail;
}
+ if (appl_context(pdu->ap_context.aos_string, 0) == NULL) {
+ log_warnx("%s: %s: Unsupported context",
+ name, ax_pdutype2string(pdu->ap_header.aph_flags));
+ error = APPL_ERROR_UNSUPPORTEDCONTEXT;
+ goto fail;
+ }
}
switch (pdu->ap_header.aph_type) {
case AX_PDU_TYPE_OPEN: