pdbt: off-by-one error fixed in carrier.c, better output for pdbt command-line interf...
authorHenning Westerholt <henning.westerholt@1und1.de>
Wed, 3 Aug 2011 15:48:44 +0000 (17:48 +0200)
committerHenning Westerholt <henning.westerholt@1und1.de>
Wed, 3 Aug 2011 15:48:44 +0000 (17:48 +0200)
utils/pdbt/carrier.c
utils/pdbt/pdbt.c

index 07de4c6..24bfa0a 100644 (file)
@@ -93,8 +93,8 @@ int load_carrier_names(char *filename) {
                        exit(-1);
                }
                
-               strncpy(cnames[id], p, len);
-               cnames[id][len]=0;
+               strncpy(cnames[id], p, len - 1);
+               cnames[id][len - 1]=0;
 
        nextline:
                n++;
index 5cc5689..afb9525 100644 (file)
@@ -546,10 +546,12 @@ void query_mmap(char *number, char *comment, void *data) {
        nmatch=dtm_longest_match(mroot, number, strlen(number), &carrierid);
 
        if (nmatch<=0) {
-               LINFO("%s: not_found: nmatch=%ld, comment='%s'\n", number, (long int)nmatch, comment);
+               LINFO("%s:%s:%ld:%s\n", number, comment, (long int)carrierid, "not allocated, probably old");
        }
        else {
-               LINFO("%s: found: carrier_id=%ld, carrier_name='%s', nmatch=%ld, comment='%s'\n", number, (long int)carrierid, carrierid2name(carrierid), (long int)nmatch, comment);
+               LINFO("%s:%s:%ld:%s\n", number, comment, (long int)carrierid, carrierid2name(carrierid));
+               /* LINFO("%s: found: carrier_id=%ld, carrier_name='%s', nmatch=%ld, comment='%s'\n", number, (long int)carrierid, carrierid2name(carrierid), (long int)nmatch, comment);
+               */
        }
 }
 
@@ -566,7 +568,9 @@ void query_server(char *number, char *comment, void *data) {
                LINFO("%s: not_found: comment='%s'\n", number, comment);
        }
        else {
-               LINFO("%s: found: carrier_id=%ld, carrier_name='%s', comment='%s'\n", number, (long int)carrierid, carrierid2name(carrierid), comment);
+               LINFO("%s:%ld:%s\n", number, (long int)carrierid, carrierid2name(carrierid));
+               /* LINFO("%s: found: carrier_id=%ld, carrier_name='%s', comment='%s'\n", number, (long int)carrierid, carrierid2name(carrierid), comment);
+               */
        }
 }