From 9f049739d7751461616b78d77960bcd4b2b7d798 Mon Sep 17 00:00:00 2001 From: cjwatson <> Date: Tue, 15 Oct 2002 22:33:37 -0800 Subject: [PATCH] [project @ 2002-10-15 23:33:37 by cjwatson] Escape control characters at the beginning of lines written to .log files, so that they don't break the state machine used by bugreport.cgi et al. --- cgi/bugreport.cgi | 1 + scripts/db2html.in | 3 ++- scripts/errorlib.in | 8 +++++++- scripts/process.in | 6 +++--- scripts/service.in | 6 +++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cgi/bugreport.cgi b/cgi/bugreport.cgi index 4e909fe3..db276a3d 100755 --- a/cgi/bugreport.cgi +++ b/cgi/bugreport.cgi @@ -259,6 +259,7 @@ while(my $line = ) { } elsif ($normstate eq 'html') { $this .= $_; } elsif ($normstate eq 'go') { + s/^\030//; if ($mail) { $mail .= $_; } else { diff --git a/scripts/db2html.in b/scripts/db2html.in index 4c5e9efd..806f28fa 100755 --- a/scripts/db2html.in +++ b/scripts/db2html.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: db2html.in,v 1.9 2002/09/25 16:16:55 doogie Exp $ +# $Id: db2html.in,v 1.10 2002/10/15 23:33:37 cjwatson Exp $ # usage: db2html [-diff] [-stampfile=] [-lastrun=] #load the necessary libraries/configuration @@ -305,6 +305,7 @@ for $f (@files) } elsif ($normstate eq 'html') { $this .= $_; } elsif ($normstate eq 'go') { + s/^\030//; $this .= &sani($_); } elsif ($normstate eq 'go-nox') { next if !s/^X//; diff --git a/scripts/errorlib.in b/scripts/errorlib.in index 85250b99..0f82ab57 100755 --- a/scripts/errorlib.in +++ b/scripts/errorlib.in @@ -1,5 +1,5 @@ # -*- perl -*- -# $Id: errorlib.in,v 1.7 2002/10/06 22:54:48 cjwatson Exp $ +# $Id: errorlib.in,v 1.8 2002/10/15 23:33:37 cjwatson Exp $ sub F_SETLK { 6; } sub F_WRLCK{ 1; } $flockstruct= 'sslll'; # And there ought to be something for this too. @@ -174,6 +174,12 @@ sub getmailbody { return undef; } +sub escapelog { + my @log = @_; + map { s/^([\01-\07\030])/\030$1/gm } @log; + return \@log; +} + @severities= @gSeverityList; @showseverities= @severities; diff --git a/scripts/process.in b/scripts/process.in index f523a563..119cd0df 100755 --- a/scripts/process.in +++ b/scripts/process.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: process.in,v 1.50 2002/10/09 00:02:33 cjwatson Exp $ +# $Id: process.in,v 1.51 2002/10/15 23:33:37 cjwatson Exp $ # # Usage: process nn # Temps: incoming/Pnn @@ -802,7 +802,7 @@ sub appendlog { print DEBUG "failed open log err $!<\n"; &quit("opening db-h/$hash/$ref.log (li): $!"); } - print(AP "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log (li): $!"); + print(AP "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log (li): $!"); close(AP) || &quit("closing db-h/$hash/$ref.log (li): $!"); } @@ -844,7 +844,7 @@ sub sendmessage { my $hash = get_hashname($ref); #save email to the log open(AP,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log (lo): $!"); - print(AP "\2\n",join("\4",@recips),"\n\5\n$msg\n\3\n") || + print(AP "\2\n",join("\4",@recips),"\n\5\n",@{escapelog($msg)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log (lo): $!"); close(AP) || &quit("closing db-h/$hash/$ref.log (lo): $!"); diff --git a/scripts/service.in b/scripts/service.in index ad784ae3..45b88cab 100755 --- a/scripts/service.in +++ b/scripts/service.in @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $Id: service.in,v 1.55 2002/10/12 18:39:01 cjwatson Exp $ +# $Id: service.in,v 1.56 2002/10/15 23:33:37 cjwatson Exp $ # ^ more or less ^ # # Usage: service .nn @@ -671,7 +671,7 @@ print(AP &sani($header{'from'})."\n". "to ".&sani($controlrequestaddr)."\n". "\3\n". - "\7\n",@log,"\n\3\n") || &quit("writing db-h/-1.log: $!"); + "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!"); close(AP) || &quit("open db-h/-1.log: $!"); &unfilelock; utime(time,time,"db-h"); @@ -887,7 +887,7 @@ sub savebug { "Request was from ".&sani($header{'from'})."\n". "to ".&sani($controlrequestaddr).". \n". "\3\n". - "\7\n",@log,"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!"); + "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!"); close(L) || &quit("closing db-h/$hash/$ref.log: $!"); open(S,">db-h/$hash/$ref.status.new") || &quit("opening db-h/$hash/$ref.status.new: $!"); print(S -- 2.39.5