aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2015-11-06 10:52:19 +0100
committerDaniel Stenberg <daniel@haxx.se>2015-11-06 10:55:30 +0100
commit60c86297bf81235c18eec68f7ddf1a30f21aa1b7 (patch)
tree75fd1e69197ddccb460751f8c2ab0bc4e592c1a7
parentcd3aba1a5c618bb20b418ac73d3627b21fb795c8 (diff)
tftp tests: verify sent options too
The tftpd test server now logs all received options and thus all TFTP test cases need to match them exactly. Extended test 283 to use and verify --tftp-blksize.
-rw-r--r--tests/data/test10075
-rw-r--r--tests/data/test10095
-rw-r--r--tests/data/test10495
-rw-r--r--tests/data/test10935
-rw-r--r--tests/data/test10945
-rw-r--r--tests/data/test109910
-rw-r--r--tests/data/test12385
-rw-r--r--tests/data/test20025
-rw-r--r--tests/data/test200310
-rw-r--r--tests/data/test200410
-rw-r--r--tests/data/test2715
-rw-r--r--tests/data/test2837
-rw-r--r--tests/data/test2845
-rw-r--r--tests/data/test2855
-rw-r--r--tests/data/test2865
-rw-r--r--tests/server/tftpd.c49
16 files changed, 111 insertions, 30 deletions
diff --git a/tests/data/test1007 b/tests/data/test1007
index 5966ab366..6baf221eb 100644
--- a/tests/data/test1007
+++ b/tests/data/test1007
@@ -32,8 +32,11 @@ This data will not be sent
</errorcode>
<protocol>
opcode: 2
-filename: /invalid-file
mode: octet
+tsize: 27
+blksize: 512
+timeout: 6
+filename: /invalid-file
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1009 b/tests/data/test1009
index b0a93e5e0..e1929beb2 100644
--- a/tests/data/test1009
+++ b/tests/data/test1009
@@ -37,8 +37,11 @@ tftp://%HOSTIP:%TFTPPORT//1009 --local-port 44444-45444
<verify>
<protocol>
opcode: 1
-filename: /1009
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /1009
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1049 b/tests/data/test1049
index e6054a478..60f41366d 100644
--- a/tests/data/test1049
+++ b/tests/data/test1049
@@ -37,8 +37,11 @@ tftp://%HOSTIP:%TFTPPORT//1049 --trace-ascii log/traceit --interface %CLIENTIP
<verify>
<protocol>
opcode: 1
-filename: /1049
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /1049
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1093 b/tests/data/test1093
index dbcfd9f7a..2087c8278 100644
--- a/tests/data/test1093
+++ b/tests/data/test1093
@@ -37,8 +37,11 @@ TFTP retrieve with mode=i
<verify>
<protocol>
opcode: 1
-filename: /1093
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /1093
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1094 b/tests/data/test1094
index 29965505f..913172260 100644
--- a/tests/data/test1094
+++ b/tests/data/test1094
@@ -43,8 +43,11 @@ TFTP retrieve with mode=netascii
<verify>
<protocol>
opcode: 1
-filename: /1094
mode: netascii
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /1094
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1099 b/tests/data/test1099
index cde403974..7aacc11d0 100644
--- a/tests/data/test1099
+++ b/tests/data/test1099
@@ -32,11 +32,17 @@ tftp://%HOSTIP:%TFTPPORT/an/invalid-file tftp://%HOSTIP:%TFTPPORT//1099 --trace-
<verify>
<protocol>
opcode: 1
-filename: an/invalid-file
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: an/invalid-file
opcode: 1
-filename: /1099
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /1099
</protocol>
<stdout>
data for 1099
diff --git a/tests/data/test1238 b/tests/data/test1238
index 18593398a..4c976c776 100644
--- a/tests/data/test1238
+++ b/tests/data/test1238
@@ -38,8 +38,11 @@ tftp://%HOSTIP:%TFTPPORT//1238 -Y1000 -y2
<verify>
<protocol>
opcode: 1
-filename: /1238
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /1238
</protocol>
# 28 = CURLE_OPERATION_TIMEDOUT
<errorcode>
diff --git a/tests/data/test2002 b/tests/data/test2002
index f39cd60f1..db96bfea8 100644
--- a/tests/data/test2002
+++ b/tests/data/test2002
@@ -88,8 +88,11 @@ TYPE I
SIZE 20020002
RETR 20020002
opcode: 1
-filename: /20020003
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /20020003
QUIT
</protocol>
<stdout>
diff --git a/tests/data/test2003 b/tests/data/test2003
index 57c0d24e6..59a743f85 100644
--- a/tests/data/test2003
+++ b/tests/data/test2003
@@ -88,11 +88,17 @@ TYPE I
SIZE 20030002
RETR 20030002
opcode: 1
-filename: /20030003
mode: octet
-opcode: 1
+tsize: 0
+blksize: 512
+timeout: 6
filename: /20030003
+opcode: 1
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /20030003
EPSV
SIZE 20030002
RETR 20030002
diff --git a/tests/data/test2004 b/tests/data/test2004
index bad6f7b90..8035183bb 100644
--- a/tests/data/test2004
+++ b/tests/data/test2004
@@ -43,11 +43,17 @@ for several protocols
<verify>
<protocol>
opcode: 1
-filename: /2004
mode: octet
-opcode: 1
+tsize: 0
+blksize: 512
+timeout: 6
filename: /2004
+opcode: 1
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /2004
</protocol>
<stdout>
Test data file
diff --git a/tests/data/test271 b/tests/data/test271
index af5a6c603..06d5a8b43 100644
--- a/tests/data/test271
+++ b/tests/data/test271
@@ -36,8 +36,11 @@ tftp://%HOSTIP:%TFTPPORT//271 --trace-ascii log/traceit
<verify>
<protocol>
opcode: 1
-filename: /271
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /271
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test283 b/tests/data/test283
index 922de51e0..0dc1270fd 100644
--- a/tests/data/test283
+++ b/tests/data/test283
@@ -17,7 +17,7 @@ tftp
TFTP retrieve on invalid file
</name>
<command>
-tftp://%HOSTIP:%TFTPPORT//invalid-file --trace-ascii log/traceit
+tftp://%HOSTIP:%TFTPPORT//invalid-file --trace-ascii log/traceit --tftp-blksize 1024
</command>
</client>
@@ -29,8 +29,11 @@ tftp://%HOSTIP:%TFTPPORT//invalid-file --trace-ascii log/traceit
</errorcode>
<protocol>
opcode: 1
-filename: /invalid-file
mode: octet
+tsize: 0
+blksize: 1024
+timeout: 6
+filename: /invalid-file
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test284 b/tests/data/test284
index 0c2a66560..954c90260 100644
--- a/tests/data/test284
+++ b/tests/data/test284
@@ -60,8 +60,11 @@ tftp://%HOSTIP:%TFTPPORT//284 --trace-ascii log/traceit
<verify>
<protocol>
opcode: 1
-filename: /284
mode: octet
+tsize: 0
+blksize: 512
+timeout: 6
+filename: /284
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test285 b/tests/data/test285
index 75a19991d..d7a4a3900 100644
--- a/tests/data/test285
+++ b/tests/data/test285
@@ -37,8 +37,11 @@ sent
</upload>
<protocol>
opcode: 2
-filename: /test285.txt
mode: octet
+tsize: 32
+blksize: 512
+timeout: 6
+filename: /test285.txt
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test286 b/tests/data/test286
index 841ee1e2a..b909fd3d5 100644
--- a/tests/data/test286
+++ b/tests/data/test286
@@ -85,8 +85,11 @@ condition in the TFTP transmit code.
</upload>
<protocol>
opcode: 2
-filename: /test286.txt
mode: octet
+tsize: 512
+blksize: 512
+timeout: 6
+filename: /test286.txt
</protocol>
</verify>
</testcase>
diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c
index cef129f2e..c2c512f11 100644
--- a/tests/server/tftpd.c
+++ b/tests/server/tftpd.c
@@ -951,6 +951,8 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
#ifdef USE_WINSOCK
DWORD recvtimeout, recvtimeoutbak;
#endif
+ char *option = (char *)"mode"; /* mode is implicit */
+ int toggle = 1;
/* Open request dump file. */
server = fopen(REQUEST_DUMP, "ab");
@@ -966,22 +968,48 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
cp = (char *)&tp->th_stuff;
filename = cp;
-again:
- while (cp < &buf.storage[size]) {
- if (*cp == '\0')
+ do {
+ bool endofit = true;
+ while (cp < &buf.storage[size]) {
+ if (*cp == '\0') {
+ endofit = false;
+ break;
+ }
+ cp++;
+ }
+ if(endofit)
+ /* no more options */
break;
- cp++;
- }
+
+ /* before increasing pointer, make sure it is still within the legal
+ space */
+ if((cp+1) < &buf.storage[size]) {
+ ++cp;
+ if(first) {
+ /* store the mode since we need it later */
+ mode = cp;
+ first = 0;
+ }
+ if(toggle)
+ /* name/value pair: */
+ fprintf(server, "%s: %s\n", option, cp);
+ else {
+ /* store the name pointer */
+ option = cp;
+ }
+ toggle ^= 1;
+ }
+ else
+ /* No more options */
+ break;
+ } while(1);
+
if (*cp) {
nak(EBADOP);
fclose(server);
return 3;
}
- if (first) {
- mode = ++cp;
- first = 0;
- goto again;
- }
+
/* store input protocol */
fprintf(server, "filename: %s\n", filename);
@@ -990,7 +1018,6 @@ again:
*cp = (char)tolower((int)*cp);
/* store input protocol */
- fprintf(server, "mode: %s\n", mode);
fclose(server);
for (pf = formata; pf->f_mode; pf++)