Fossil SCM
Bug in ipPrefix (Check-in [86cbb69af2])?
Fixed
a09798ba9e285df…
· opened 16 years, 3 months ago
- Type
- Code_Defect
- Priority
- —
- Severity
- —
- Resolution
- Fixed
- Subsystem
- —
- Created
- Dec. 29, 2009 1:49 p.m.
You sure that
return mprintf("%.*s", j, zIP);
is correct? It's been a long time having programmed in C, but I think you should use i instead of j (j will be 2 at most).
rwilson added on 2009-12-29 18:16:42:
i think you are correct. it should be i. as is, this code will always return the first two chars of the ip address.
static char *ipPrefix(const char *zIP){
int i, j;
for(i=j=0; zIP[i]; i++){
if( zIP[i]=='.' ){
j++;
if( j==2 ) break;
}
}
return mprintf("%.*s", j, zIP);
}
drh added on 2009-12-29 20:53:21:
See check-in [5d16ca43f192].