[PATCH] randomtrain utility gets confused by spams with null bytes

Greg Louis glouis at dynamicro.on.ca
Sun Dec 8 22:57:07 CET 2002


On 20021208 (Sun) at 1901:21 +0100, Matthias Andree wrote:
> Greg Louis <glouis at dynamicro.on.ca> writes:
> 
> > The randomtrain script invokes grep without the -a option and therefore
> > fails if a file it needs to process is deemed binary.  Some spam
> > contains null bytes (hex 00) in the body of the text, and will cause
> > this failure.
> >
> > --- contrib/randomtrain~	2002-12-08 12:01:15.000000000 -0500
> > +++ contrib/randomtrain	2002-12-08 12:01:15.000000000 -0500
> > @@ -69,7 +69,7 @@
> >      test "$indic" != "s" -a "$indic" != "n" && usage
> >      file=$1 ; shift
> >      if [ ! -r $file ]; then echo "$file not found"; usage; fi
> > -    grep -b '^From ' $file | \
> > +    grep -a -b '^From ' $file | \
> >  	awk "BEGIN {FS=\":\"} {print \"$indic $file \"\$1}" >>list.$pid
> >      wc -c $file | awk "{print \"$indic $file \"\$1}" >>list.$pid
> >  done
> 
> My Solaris version of grep does not have the -a switch and will barf:
> 

Unfortunately, the -b option isn't very portable either, as I pointed
out re HP-UX initially.  Using gnu grep for this is the solution on
that architecture.

-- 
| G r e g  L o u i s          | gpg public key:      |
|   http://www.bgl.nu/~glouis |   finger greg at bgl.nu |




More information about the Bogofilter mailing list