diff --git a/CHANGELOG b/CHANGELOG index f2d2358..106e2f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,7 +5,11 @@ iodine - http://code.kryo.se/iodine CHANGES: -2009-01-10: 0.5.0-rc1 "iPassed" +2009-01-17: 0.5.0-rc2 + - Fixed endless loop in fragment size autodetection, #39. + - Fixed broken hostname dot placing with specific lengths, #40. + +2009-01-10: 0.5.0-rc1 - Fixed segfault in server when sending version reject. - Applied patch to make iodine build on BeOS R5-BONE and Haiku, from Francois Revol. Still work to do to get tun device working. diff --git a/src/encoding.c b/src/encoding.c index 7f4c924..6878e5e 100644 --- a/src/encoding.c +++ b/src/encoding.c @@ -52,12 +52,12 @@ inline_dotify(char *buf, size_t buflen) pos = (unsigned) (reader - buf) + 1; while (dots) { + *writer-- = *reader--; + pos--; if (pos % 57 == 0) { *writer-- = '.'; dots--; } - *writer-- = *reader--; - pos--; } /* return new length of string */ diff --git a/src/iodine.c b/src/iodine.c index 0dd7a19..35eb104 100644 --- a/src/iodine.c +++ b/src/iodine.c @@ -539,12 +539,12 @@ handshake(int dns_fd) printf("Version ok, both using protocol v 0x%08x. You are user #%d\n", VERSION, userid); goto perform_login; } else if (strncmp("VNAK", in, 4) == 0) { - errx(1, "You use protocol v 0x%08x, server uses v 0x%08x. Giving up", + warnx("You use protocol v 0x%08x, server uses v 0x%08x. Giving up", VERSION, payload); - /* NOTREACHED */ + return 1; } else if (strncmp("VFUL", in, 4) == 0) { - errx(1, "Server full, all %d slots are taken. Try again later", payload); - /* NOTREACHED */ + warnx("Server full, all %d slots are taken. Try again later", payload); + return 1; } } else warnx("did not receive proper login challenge"); @@ -601,8 +601,8 @@ perform_login: printf("Retrying login...\n"); } - errx(1, "couldn't login to server"); - /* NOTREACHED */ + warnx("couldn't login to server"); + return 1; perform_case_check: case_preserved = 0; @@ -703,7 +703,7 @@ autodetect_max_fragsize: int range = 768; max_downstream_frag_size = 0; printf("Autoprobing max downstream fragment size... (skip with -m fragsize)\n"); - while (range >= 8 || !max_downstream_frag_size) { + while (running && range > 0 && (range >= 8 || !max_downstream_frag_size)) { for (i=0; running && i<3 ;i++) { tv.tv_sec = 1; tv.tv_usec = 0; @@ -736,6 +736,17 @@ autodetect_max_fragsize: range >>= 1; proposed_fragsize -= range; } + if (!running) { + printf("\n"); + warnx("stopped while autodetecting fragment size (Try probing manually with -m)"); + return 1; + } + if (range == 0) { + /* Tried all the way down to 2 and found no good size */ + printf("\n"); + warnx("found no accepted fragment size. (Try probing manually with -m)"); + return 1; + } printf("will use %d\n", max_downstream_frag_size); } printf("Setting downstream fragment size to max %d...\n", max_downstream_frag_size); diff --git a/tests/encoding.c b/tests/encoding.c index 7b256bd..a5d04fa 100644 --- a/tests/encoding.c +++ b/tests/encoding.c @@ -31,6 +31,8 @@ struct tuple "aaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaa"}, { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa."}, + { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}, { "abc123", "abc123" }, { NULL, NULL } };