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

Atomic configuration has trouble with large integers #255

Closed
ydahhrk opened this Issue Nov 25, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@ydahhrk
Member

ydahhrk commented Nov 25, 2017

"Mark" is a 32-bit integer. This atomic configuration file should yield a predictable result:

{
	"pool4": [
		{
			"mark": 4294967295,
			"prefix": "192.0.2.1",
			"protocol": "UDP"
		}
	]
}

But this happens in my VM:

$ jool --pool4 --display
+------------+-------+--------------------+-----------------+----------+----------+
|       Mark | Proto |     Max iterations |         Address | Port min | Port max |
+------------+-------+--------------------+-----------------+----------+----------+
| 2147483648 |   UDP |       1024 ( auto) |       192.0.2.1 |    61001 |    65535 |
+------------+-------+--------------------+-----------------+----------+----------+
  (Fetched 1 samples.)

If inserted with --pool4 --add it works fine. The problem is that the Json parser reads integers as signed, so the entire second half of the unsigned range is wasted. Therefore, this bug presumably only affects 32-bit machines. (Or any machine that interprets int as 32-bits.)

Assigning out-of-bounds values into variables is considered undefined behaviour in C, so YMMV on the results.

@ydahhrk ydahhrk closed this in 1d44974 Nov 28, 2017

@ydahhrk ydahhrk added this to the 3.5.6 milestone Jan 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment