Skip to content

Commit

Permalink
staging: usbip: fix potential segfault because of unchecked return va…
Browse files Browse the repository at this point in the history
…lue of strchr.

This doesn't happen with the usbip virtual hci module, but another
module wanting to interface with this user space code could cause a
seg-fault by sending data without newlines.

Signed-off-by: Christopher Harvey <charvey@matrox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Christopher Harvey authored and Greg Kroah-Hartman committed Apr 10, 2012
1 parent 310c6a7 commit 2f5c638
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions drivers/staging/usbip/userspace/libsrc/vhci_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ static int parse_status(char *value)


/* skip a header line */
c = strchr(value, '\n') + 1;
c = strchr(value, '\n');
if (!c)
return -1;
c++;

while (*c != '\0') {
int port, status, speed, devid;
Expand Down Expand Up @@ -109,7 +112,10 @@ static int parse_status(char *value)


/* go to the next line */
c = strchr(c, '\n') + 1;
c = strchr(c, '\n');
if (!c)
break;
c++;
}

dbg("exit");
Expand Down Expand Up @@ -264,11 +270,17 @@ static int get_nports(void)
attr_status->method, attr_status->value);

/* skip a header line */
c = strchr(attr_status->value, '\n') + 1;
c = strchr(attr_status->value, '\n');
if (!c)
return 0;
c++;

while (*c != '\0') {
/* go to the next line */
c = strchr(c, '\n') + 1;
c = strchr(c, '\n');
if (!c)
return nports;
c++;
nports += 1;
}

Expand Down

0 comments on commit 2f5c638

Please sign in to comment.