diff options
author | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-01-12 16:43:02 +0000 |
---|---|---|
committer | Pierre-Yves Ritschard <pyr@cvs.openbsd.org> | 2007-01-12 16:43:02 +0000 |
commit | c5afe0ba568d248ece5fca0f35c20df84a862bd2 (patch) | |
tree | 00fe7910a0ecaeda88215922e4c0772de83ae9b8 /usr.sbin/relayd/parse.y | |
parent | 2bebcfa9da8ac1420312c59ac375bbb6c4880cb0 (diff) |
eliminate duplicate tcp read/write code.
ok claudio@, reyk@
Diffstat (limited to 'usr.sbin/relayd/parse.y')
-rw-r--r-- | usr.sbin/relayd/parse.y | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index e3428244243..541bb752cd5 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.15 2007/01/09 13:50:11 pyr Exp $ */ +/* $OpenBSD: parse.y,v 1.16 2007/01/12 16:43:01 pyr Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -176,15 +176,12 @@ varset : STRING '=' STRING { ; sendbuf : NOTHING { - bzero(table->sendbuf, sizeof(table->sendbuf)); + table->sendbuf = NULL; } | STRING { - if (strlcpy(table->sendbuf, $1, sizeof(table->sendbuf)) - >= sizeof(table->sendbuf)) { - yyerror("yyparse: send buffer truncated"); - free($1); - YYERROR; - } + table->sendbuf = strdup($1); + if (table->sendbuf == NULL) + fatal("out of memory"); free($1); } ; @@ -386,30 +383,25 @@ tableoptsl : host { | CHECK HTTP STRING CODE number { table->check = CHECK_HTTP_CODE; table->retcode = $5; - if (strlcpy(table->path, $3, sizeof(table->path)) >= - sizeof(table->path)) { - yyerror("http path truncated"); - free($3); - YYERROR; - } + asprintf(&table->sendbuf, "HEAD %s HTTP/1.0\r\n\r\n", + $3); + free($3); + if (table->sendbuf == NULL) + fatal("out of memory"); } | CHECK HTTP STRING DIGEST STRING { table->check = CHECK_HTTP_DIGEST; - if (strlcpy(table->path, $3, sizeof(table->path)) >= - sizeof(table->path)) { - yyerror("http path truncated"); - free($3); - free($5); - YYERROR; - } + asprintf(&table->sendbuf, "GET %s HTTP/1.0\r\n\r\n", + $3); + free($3); + if (table->sendbuf == NULL) + fatal("out of memory"); if (strlcpy(table->digest, $5, sizeof(table->digest)) >= sizeof(table->digest)) { yyerror("http digest truncated"); - free($3); free($5); YYERROR; } - free($3); free($5); } | CHECK SEND sendbuf EXPECT STRING { |