summaryrefslogtreecommitdiff
path: root/tools/skrewt.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-14 16:19:15 -0700
committerJohn Denker <jsd@av8n.com>2012-07-14 16:19:15 -0700
commit7fbe472c452717e4e5d08cd5905184012d788c0a (patch)
treef45e7f35c28bd1c7065efdedc5c6af1121cb2c12 /tools/skrewt.c
parentf639924b1c6e014a458f34e45133d50990887050 (diff)
implement size-limit
Diffstat (limited to 'tools/skrewt.c')
-rw-r--r--tools/skrewt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/skrewt.c b/tools/skrewt.c
index da0ed64..8ae4db4 100644
--- a/tools/skrewt.c
+++ b/tools/skrewt.c
@@ -100,12 +100,15 @@ int main(int argc, char** argv){
int text_type(1);
int textlines(0);
int gotdate(0);
+ int msgsize(0);
+ int msgmax(1000000);
for (;;){
if (cin.eof()) break;
if (cin.bad()) return 1;
if (inheads) {
string header;
if (getline(cin, header).fail()) continue;
+ msgsize += header.length()+1;
for (;;) {
if (cin.eof()) break;
if (cin.bad()) return 1;
@@ -115,6 +118,11 @@ int main(int argc, char** argv){
if (ch != ' ' && ch != '\t') break;
string line;
if (getline(cin, line).fail()) continue;
+ msgsize += line.length()+1;
+ if (msgsize > msgmax) {
+ cerr << "skrewt rejection: bigger than " << msgmax << endl;
+ exit(1);
+ }
header += "\n" + line;
}
if (header.length() == 0) {
@@ -176,6 +184,11 @@ int main(int argc, char** argv){
} else {
string line;
if (!getline(cin, line).fail()) {
+ msgsize += line.length()+1;
+ if (msgsize > msgmax) {
+ cerr << "skrewt rejection: bigger than " << msgmax << endl;
+ exit(1);
+ }
if (line == "--" + boundary) {
inheads = 1;
} else {