#!/usr/local/bin/perl # # history database sanity checker # David Barr # version 1.3 # Throw away history entries with: # malformed lines (too long, contain nulls or special characters) # # INN Usage: # ctlinnd throttle 'fixing history' # ./fixhist history.n # makehistory -r -s `wc -l ) { chop; ($msgid,$dates,$arts,$xtra) = split('\t'); if ($xtra) { &tossit(); # too many fields next; } if (!($dates) && (($arts) || ($xtra))) { &tossit(); # if not date field, then the rest next; # should be empty } if (length($msgid) >= $MAXKEYLEN) { &tossit(); # message-id too long next; } if ($msgid !~ /^<[^<> ]*>$/) { &tossit(); # malformed msg-ids next; } if (/[\000-\010\012-\037\177-\237]/) { # non-control chars except tab &tossit(); # illegal chars next; } if ($dates) { if ($dates =~ /[^\d~\-]/) { # rudimentary check &tossit(); next; } } print "$_\n"; $count++; } print STDERR "Done. Now run:\nmakehistory -r -s $count -f history.n\n"; sub tossit { print STDERR "$_\n"; }