application.c checks the context where applicable, but not every agentx-pdu goes through there (e.g. agentx-ping-pdu). Make sure we always check the context in appl_agentx_recv()
OK? martijn@ diff --git a/application.c b/application.c index dd92864..a02260b 100644 --- a/application.c +++ b/application.c @@ -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/application.h b/application.h index 8b2c567..949bbde 100644 --- a/application.h +++ b/application.h @@ -121,6 +121,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/application_agentx.c b/application_agentx.c index c11b666..6a4ed49 100644 --- a/application_agentx.c +++ b/application_agentx.c @@ -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) == 0) { + 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: