Bug #2253
closedsubscriber create-on-demand random numbers are parsed wrongly
100%
Description
Numbers entered in the VTY mismatch the show running-config output.
OpenBSC(config-nitb)# subscriber-create-on-demand random 9570000000 9579999999
OpenBSC(config-nitb)# show running-config
[...]
nitb
subscriber-create-on-demand
subscriber-create-on-demand random 980065408 990065407
assign-tmsi
Updated by neels almost 7 years ago
The problem is the use of atoi() which truncates to 32bit.
9570000000 & 0xffffffff = 980065408
(even though I'm testing on a 64bit machine, I'm still seeing 32bit truncation by atoi)
Updated by neels almost 7 years ago
interestingly enough, atol() and atoll() show the same behavior o_O
▶ cat atoi.c #include <stdio.h> int main(int argc, char **argv) { long long int x = atoi(argv[1]); long long int y = atol(argv[1]); long long int z = atoll(argv[1]); long long int xx = 9570000000; printf("atoi %lld\n", x); printf("atol %lld\n", y); printf("atoll %lld\n", z); printf("xx %lld\n", xx); return 0; } ▶ make atoi cc atoi.c -o atoi ▶ ./atoi 9570000000 atoi 980065408 atol 980065408 atoll 980065408 xx 9570000000
Updated by neels almost 7 years ago
That's peculiar. atol* change their behavior depending on whether <stdlib.h> was included or not.
▶ cat atoi2.c #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { long long int x = atoi(argv[1]); long long int y = atol(argv[1]); long long int z = atoll(argv[1]); long long int xx = 9570000000; printf("atoi %lld\n", x); printf("atol %lld\n", y); printf("atoll %lld\n", z); printf("xx %lld\n", xx); return 0; } ▶ make atoi2 cc atoi2.c -o atoi2 ▶ ./atoi2 9570000000 atoi 980065408 atol 9570000000 atoll 9570000000 xx 9570000000
Updated by neels almost 7 years ago
When the VTY range parsing is fixed, there's more problems during subscriber creation also truncating the extension to 32bit.
Updated by neels almost 7 years ago
both issues fixed in https://gerrit.osmocom.org/2583 https://gerrit.osmocom.org/2584
Updated by neels almost 7 years ago
- Status changed from New to Resolved
- Assignee changed from 118 to neels
- % Done changed from 0 to 100
above patches merged.