avoid parsing InformationBuffer unless status is "success"
authorBjørn Mork <bjorn@mork.no>
Wed, 8 Apr 2015 13:31:20 +0000 (15:31 +0200)
committerJohn Crispin <blogic@openwrt.org>
Fri, 3 Apr 2015 08:33:14 +0000 (10:33 +0200)
The MBIM specification requires that the InformationBuffer
is empty unless the status field is MBIM_STATUS_SUCCESS,
except for 4 explicit combinations of status code and
command id.

Avoid calling the reply handler if the status code is
non-zero and the information buffer is empty.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
mbim-dev.c

index af76683fc09a52f9ebf7cf8ed72301748ed71949..4474b2d2220d9226eb5eb777c9239be0426a6a4c 100644 (file)
@@ -107,7 +107,10 @@ mbim_recv(struct uloop_fd *u, unsigned int events)
        case MBIM_MESSAGE_TYPE_COMMAND_DONE:
                if (verbose)
                        printf("  status_code: %04X\n", le32toh(msg->status_code));
-               return_code = current_handler->response(msg->buffer, le32toh(msg->buffer_length));
+               if (msg->status_code && !msg->buffer_length)
+                       return_code = -le32toh(msg->status_code);
+               else
+                       return_code = current_handler->response(msg->buffer, le32toh(msg->buffer_length));
                if (return_code < 0)
                        no_close = 0;
                mbim_send_close_msg();