View Ticket
Not logged in
Ticket UUID: a09798ba9e285df66543f60344e7109fe6ac125c
Title: Bug in ipPrefix (Check-in 86cbb69af2)?
Status: Fixed Type: Code_Defect
Severity: Priority:
Subsystem: Resolution: Fixed
Last Modified: 2009-12-29 20:53:21
Version Found In: c5e94568c7
Description & Comments:
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[bad-link: i]i; i++){
    if( zIP[bad-link: i]i=='.' ){
      j++;
      if( j==2 ) break;
    }
  }
  return mprintf("%.*s", j, zIP);
}

drh added on 2009-12-29 20:53:21:
See check-in 5d16ca43f192.