[openib-general] [PATCH][TRIVIAL] libibmad/src/rpc.c: Validate num_classes
Hal Rosenstock
halr at voltaire.com
Wed Aug 30 09:33:13 PDT 2006
libibmad/src/rpc.c: Validate num_classes
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
Index: libibmad/src/rpc.c
===================================================================
--- libibmad/src/rpc.c (revision 9192)
+++ libibmad/src/rpc.c (working copy)
@@ -306,6 +306,9 @@ madrpc_init(char *dev_name, int dev_port
if ((mad_portid = umad_open_port(dev_name, dev_port)) < 0)
IBPANIC("can't open UMAD port (%s:%d)", dev_name, dev_port);
+ if (num_classes >= MAX_CLASS)
+ IBPANIC("too many classes %d requested", num_classes);
+
while (num_classes--) {
int rmpp_version = 0;
int mgmt = *mgmt_classes++;
@@ -324,6 +327,12 @@ mad_rpc_open_port(char *dev_name, int de
struct ibmad_port *p;
int port_id;
+ if (num_classes >= MAX_CLASS) {
+ IBWARN("too many classes %d requested", num_classes);
+ errno = EINVAL;
+ return NULL;
+ }
+
if (umad_init() < 0) {
IBWARN("can't init UMAD library");
errno = ENODEV;
More information about the general
mailing list