-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix xtreme8000#96 error when starting client with aos version in url #189
base: standalone
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1008,16 +1008,24 @@ int network_identifier_split(char* addr, char* ip_out, int* port_out) { | |
if((size_t)ip_start <= 6) | ||
return 0; | ||
char* port_start = strchr(ip_start, ':'); | ||
*port_out = port_start ? strtoul(port_start + 1, NULL, 10) : 32887; | ||
|
||
if(strchr(ip_start, '.')) { | ||
if(port_start) { | ||
strncpy(ip_out, ip_start, port_start - ip_start); | ||
ip_out[port_start - ip_start] = 0; | ||
} else { | ||
strcpy(ip_out, ip_start); | ||
} | ||
} else { | ||
// parse port, also ignore anything past another ':' (e.g. version info) | ||
int next_colon = strchr(port_start + 1, ':'); | ||
*port_out = strtoul(port_start + 1, next_colon, 10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. next_colon should be passed as a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this PR even do anything different to the original code, except the additional ip length check??? |
||
|
||
// if no port is specified (conversion fails), use default port | ||
if(*port_out == 0) | ||
*port_out = 32887; | ||
|
||
int ip_length = port_start - ip_start; | ||
if(ip_length > 32) { | ||
return 0; // invalid ip | ||
} | ||
|
||
strncpy(ip_out, ip_start, ip_length); | ||
ip_out[ip_length] = 0; | ||
|
||
if(!strchr(ip_out, '.')) { | ||
unsigned int ip = strtoul(ip_start, NULL, 10); | ||
sprintf(ip_out, "%i.%i.%i.%i", ip & 255, (ip >> 8) & 255, (ip >> 16) & 255, (ip >> 24) & 255); | ||
} | ||
|
@@ -1030,9 +1038,9 @@ int network_connect_string(char* addr) { | |
int port; | ||
if(!network_identifier_split(addr, ip, &port)) | ||
return 0; | ||
|
||
return network_connect(ip, port); | ||
} | ||
|
||
int network_update() { | ||
if(network_connected) { | ||
if(window_time() - network_stats_last >= 1.0F) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is next_colon of type
int
even though strchr returnschar*