looking at version 1.0.1 code, line 122 of meta.c has lenin = recv(...).
then it is checked (line 124).
at line 140, you have while (lenin) { ... }
then you pass in lenin into DecryptUpdate, and lenin gets modified
to a "new" value. looking at the manage for EVP_DecryptUpdate it
says something about if padding is enabled you must have enough
space for the decrypted block, so there's a possibility that lenin
will be different after the call.
later on, with receiving tcp packets, lenin is shrunk by the
size of the tcplen packet, and if we didn't get enough data,
go back to the beginning of the while loop, at 140.
BUT!!! before that jump happens, tcplen is reset to 0.
so we have a case where, if receive_tcppacket gets less data
than the entire size of the tcp packet, i believe it may be possible
to get into a weird state.
where:
- lenin is non-zero
- tcplen is zero
- the entire tcp packet has not yet been read
consequently, things could go thoroughly pear-shaped, including
possibly lenin going negative, as noted.
so, really:
- there should be checks added to ensure that lenin never
goes negative (while lenin >= 0) and then after the while loop,
report a possible error condition if lenin < 0
- resetting c->tcplen to 0 probably isn't a good idea [unless i have
misunderstood things here].
it _could_ just be that a decrypt has failed [the error condition
of EVP_DecryptUpdate isn't checked nor an error reported]
... am i helping? :)
l.
--
--
expecting email to be received and understood is a bit like
picking up the telephone and immediately dialing without
checking for a dial-tone; speaking immediately without listening
for either an answer or ring-tone; hanging up immediately and
then expecting someone to call you (and to be able to call you).
--
every day, people send out email expecting it to be received
without being tampered with, read by other people, delayed or
simply - without prejudice but lots of incompetence - destroyed.
--
please therefore treat email more like you would a CB radio
to communicate across the world (via relaying stations):
ask and expect people to confirm receipt; send nothing that
you don't mind everyone in the world knowing about...
--
TINC development list, tinc-...@nl.linux.org
Archive: http://mail.nl.linux.org/tinc-devel/
> looking at version 1.0.1 code, line 122 of meta.c has lenin = recv(...).
[..]
> ... am i helping? :)
Well, it's already fixed in CVS :).
--
Met vriendelijke groet / with kind regards,
Guus Sliepen <gu...@sliepen.eu.org>