Skip to content

Commit

Permalink
Merge pull request #5 from westermo/usr/wkz/use-after-free-fix
Browse files Browse the repository at this point in the history
Fix use-after-free on machines with unsigned-by-default chars
  • Loading branch information
jackuess authored Oct 10, 2022
2 parents 1788b28 + d328bef commit d8f2b88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions src/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,28 @@ static int populate(void)
return -1;

while (fgets(buf, sizeof(buf), fp)) {
char br[5], port[16], group[64], opt[10];
int vid, n;
char br[5], port[16], group[64];
char *tok, *dst;
int vid = 0;

for (tok = strtok(buf, " \t"); tok; tok = strtok(NULL, " \t")) {
if (!strcmp(tok, "dev")) {
dst = br;
} else if (!strcmp(tok, "port")) {
dst = port;
} else if (!strcmp(tok, "grp")) {
dst = group;
} else if (!strcmp(tok, "vid")) {
tok = strtok(NULL, " \t");
vid = strtol(tok, NULL, 10);
continue;
} else {
continue;
}

n = sscanf(buf, "dev %s port %s grp %s %s vid %d", br, port, group, opt, &vid);
tok = strtok(NULL, " \t");
strcpy(dst, tok);
}

/* XXX: Filter out IPv6 and MAC for now ... */
if (strchr(group, ':'))
Expand Down
2 changes: 1 addition & 1 deletion src/pev.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct pev {

int id;
char type;
char active;
signed char active;

union {
int sd;
Expand Down

0 comments on commit d8f2b88

Please sign in to comment.