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

Traffic Router (TR) czCount integer overflow in Traffic Ops (TO) #7252

Closed
tcfdev opened this issue Dec 14, 2022 · 1 comment · Fixed by #7272
Closed

Traffic Router (TR) czCount integer overflow in Traffic Ops (TO) #7252

tcfdev opened this issue Dec 14, 2022 · 1 comment · Fixed by #7272
Labels
bug something isn't working as intended low difficulty the estimated level of effort to resolve this issue is low low impact affects only a small portion of a CDN, and cannot itself break one Traffic Router related to Traffic Router

Comments

@tcfdev
Copy link
Collaborator

tcfdev commented Dec 14, 2022

This Bug Report affects these Traffic Control components:

  • Traffic Ops
  • Traffic Router

Current behavior:

Traffic Ops queries the Traffic Router endpoint crs/stats to parse / process / display information. The struct is expecting the czCount field to be a uint64 however in at least one instance the value returned was negative (implying an Integer Overflow in TR).

From the TO error log:

ERROR: api.go:263: <id addr> decoding stats from CDN <CDN name> <traffic router>: json: cannot unmarshal number -2054406724 into Go struct field CRSStatsStat.stats.HTTPMap.czCount of type uint64

Looking into the response from TR, one of the routers reported:

	"server": {
		"czCount": -2055404181, <--- The culprit
		"geoCount": 26857914,
		"deepCzCount": 0,
		"missCount": 1498,
		"dsrCount": 0,
		"errCount": 0,
		"staticRouteCount": 0,
		"fedCount": 0,
		"regionalDeniedCount": 0,
		"regionalAlternateCount": 0
	},

Expected behavior:

The czCount field should certainly not be negative to prevent the bug from happening. However there may a bigger question in terms of "What to do when we've hit the max allowable value of a uint64? Is resetting the values considered appropriate?"

Steps to reproduce:

Whew uhh. Hit an endpoint more than 2 147 483 647 times to see if it rolls over (since Java doesn't have unsigned integer types).

@tcfdev tcfdev added the bug something isn't working as intended label Dec 14, 2022
@ocket8888 ocket8888 added Traffic Router related to Traffic Router low impact affects only a small portion of a CDN, and cannot itself break one low difficulty the estimated level of effort to resolve this issue is low labels Dec 14, 2022
@ocket8888
Copy link
Contributor

ocket8888 commented Dec 14, 2022

Java doesn't have unsigned integer types

That's literally true, but it does provide ways to interpret the data value of a signed integer in unsigned ways. Specifically, the serialization of a count of something should be using the toUnsignedString static method of Java's Integer class. Just an FYI for anyone fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working as intended low difficulty the estimated level of effort to resolve this issue is low low impact affects only a small portion of a CDN, and cannot itself break one Traffic Router related to Traffic Router
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants