Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #782 #784 #785 #786 #787 #788 strtok r isuses #801

Merged
merged 5 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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