Skip to content

Commit

Permalink
Merge pull request #801 from appneta/Bug_#782_#784_#785_#786_#787_#78…
Browse files Browse the repository at this point in the history
…8_strtok_r_isuses

Bug #782 #784 #785 #786 #787 #788 strtok r isuses
  • Loading branch information
fklassen committed Jun 5, 2023
2 parents 22ecbca + bfab833 commit 128ecaf
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG
@@ -1,6 +1,8 @@
06/04/2023 Version 4.4.4-beta1
- CVE-2023-27786 bugs caused by strtok_r (#782 #784 #785 #786 #787 #788)
- CVE-2023-27783 reachable assert in tcpedit_dlt_cleanup (#780)
- add CI - C/C++ Linter and CodeQL (#773)

01/01/2023 Version 4.4.3
- upgrade autogen/libopts to version 5.18.16 (#759)
- avoid implicit int in configure.ac (#757)
Expand Down
4 changes: 4 additions & 0 deletions src/common/cidr.c
Expand Up @@ -253,6 +253,8 @@ parse_cidr(tcpr_cidr_t **cidrdata, char *cidrin, char *delim)

/* first iteration of input using strtok */
network = strtok_r(cidrin, delim, &token);
if (network == NULL)
return 0;

*cidrdata = cidr2cidr(network);
cidr_ptr = *cidrdata;
Expand Down Expand Up @@ -320,6 +322,8 @@ parse_endpoints(tcpr_cidrmap_t **cidrmap1, tcpr_cidrmap_t **cidrmap2, const char
/* ipv4 mode */
memset(newmap, '\0', NEWMAP_LEN);
map = strtok_r(string, ":", &token);
if (map == NULL)
goto done;

strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN);
strlcat(newmap, map, NEWMAP_LEN);
Expand Down
2 changes: 1 addition & 1 deletion src/common/list.c
Expand Up @@ -74,7 +74,7 @@ parse_list(tcpr_list_t **listdata, char *ourstr)
second = NULL;

/* regex test */
if (regexec(&preg, this, 0, NULL, 0) != 0) {
if (this == NULL || regexec(&preg, this, 0, NULL, 0) != 0) {
warnx("Unable to parse: %s", this);
regfree(&preg);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/common/mac.c
Expand Up @@ -112,7 +112,7 @@ macinstring(const char *macstring, const u_char *mac)
memset(&tempmac[0], 0, sizeof(tempmac));

tempstr = strtok_r(ourstring, ",", &tok);
if (strlen(tempstr)) {
if (tempstr != NULL && strlen(tempstr)) {
mac2hex(tempstr, tempmac, len);
if (memcmp(mac, tempmac, len) == 0) {
dbgx(3, "Packet matches: " MAC_FORMAT " sending out primary.\n", MAC_STR(tempmac));
Expand Down
2 changes: 2 additions & 0 deletions src/common/utils.c
Expand Up @@ -336,6 +336,8 @@ read_hexstring(const char *l2string, u_char *hex, int hexlen)

/* get the first byte */
l2byte = strtok_r(string, ",", &token);
if (l2byte == NULL)
err(-1, "Hex buffer must contain something");
value = strtol(l2byte, NULL, 16);
if (value > 0xff)
errx(-1, "Invalid hex string byte: %s", l2byte);
Expand Down
2 changes: 1 addition & 1 deletion src/tcpedit/portmap.c
Expand Up @@ -188,7 +188,7 @@ parse_portmap(tcpedit_portmap_t **portmap, const char *ourstr)
/* first iteration of input */
substr = strtok_r(ourstrcpy, ",", &token);

if ((*portmap = ports2PORT(substr)) == NULL) {
if (substr == NULL || (*portmap = ports2PORT(substr)) == NULL) {
safe_free(ourstrcpy);
return 0;
}
Expand Down

0 comments on commit 128ecaf

Please sign in to comment.