simon-git: putty (master): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Wed Jun 6 20:21:13 BST 2018
TL;DR:
452114c New memory management macro 'snew_plus'.
61a972c Make share_got_pkt_from_server take a const pointer.
ce6c65a Separate Packet into two structures.
bf3c9df Remove body and length fields from PktIn.
ea04bf3 Remove data and maxlen fields from PktIn.
8c4680a Replace PktOut body pointer with a prefix length.
eb5bc31 Make PktIn contain its own PacketQueueNode.
0df6303 Fix a valgrind error.
Repository: https://git.tartarus.org/simon/putty.git
On the web: https://git.tartarus.org/?p=simon/putty.git
Branch updated: master
Committer: Simon Tatham <anakin at pobox.com>
Date: 2018-06-06 20:21:13
commit 452114c3d3f4340d14f1117055f0deaecb9e64ef
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=452114c3d3f4340d14f1117055f0deaecb9e64ef;hp=22d2c721013ee229d154af43a074539e439ffbba
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Jun 6 06:42:52 2018 +0100
New memory management macro 'snew_plus'.
This formalises my occasional habit of using a single malloc to make a
block that contains a header structure and a data buffer that a field
of the structure will point to, allowing it to be freed in one go
later. Previously I had to do this by hand, losing the type-checking
advantages of snew; now I've written an snew-style macro to do the
job, plus an accessor macro to cleanly get the auxiliary buffer
pointer afterwards, and switched existing instances of the pattern
over to using that.
puttymem.h | 15 +++++++++++++++
sshshare.c | 11 ++++-------
unix/gtkfont.c | 10 ++++------
3 files changed, 23 insertions(+), 13 deletions(-)
commit 61a972c3326abe0a0276cda48ac15c9195f4b161
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=61a972c3326abe0a0276cda48ac15c9195f4b161;hp=452114c3d3f4340d14f1117055f0deaecb9e64ef
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Jun 6 07:19:57 2018 +0100
Make share_got_pkt_from_server take a const pointer.
It was horrible - even if harmless in practice - that it wrote the
NATed channel id over its input buffer, and I think it's worth the
extra memory management to avoid doing that.
ssh.h | 2 +-
sshshare.c | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
commit ce6c65aba1e11e7293cefc0d9d2bd7377582edf5
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=ce6c65aba1e11e7293cefc0d9d2bd7377582edf5;hp=61a972c3326abe0a0276cda48ac15c9195f4b161
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Jun 5 08:20:10 2018 +0100
Separate Packet into two structures.
This is the first stage of massively tidying up this very confused
data structure. In this commit, I replace the unified 'struct Packet'
with two structures PktIn and PktOut, each of which contains only the
fields of struct Packet that are actually used for packets going in
that direction - most notably, PktIn doesn't implement BinarySink, and
PktOut doesn't implement BinarySource.
All uses of the old structure were statically determinable to be one
or the other, so I've done that determination and changed all the
types of variables and function signatures.
Unlike PktIn, PktOut is not reference-counted, so there's a new
ssh_pktout_free function.
The most immediately pleasing thing about this change is that it lets
me finally get rid of the tedious comment explaining how the 'length'
field in struct Packet meant something different depending on
direction. Now it's two fields of the same name in two different
structures, I can comment the same thing much less verbosely!
(I've also got rid of the comment claiming the type field was only
used for incoming packets. That wasn't even true! It might have been
once, because you can write an outgoing packet's type byte straight
into its data buffer, but in fact in the current code pktout->type is
nonetheless used in various other places, e.g. log_outgoing_packet.)
In this commit I've only removed the fields from each structure that
were _already_ unused. There are still quite a few we can get rid of
by _making_ them unused.
ssh.c | 381 ++++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 196 insertions(+), 185 deletions(-)
commit bf3c9df54a9ed55088d7c381f3798095ae48767e
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=bf3c9df54a9ed55088d7c381f3798095ae48767e;hp=ce6c65aba1e11e7293cefc0d9d2bd7377582edf5
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Jun 6 07:17:09 2018 +0100
Remove body and length fields from PktIn.
They were duplicating values stored in the BinarySource substructure.
Mostly they're not referred to directly any more (instead, we call
get_foo to access the BinarySource); and when they are, we can switch
to reading the same values back out of the BinarySource anyway.
ssh.c | 93 ++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 44 insertions(+), 49 deletions(-)
commit ea04bf3da98173b22325dee30acca9146cc24851
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=ea04bf3da98173b22325dee30acca9146cc24851;hp=bf3c9df54a9ed55088d7c381f3798095ae48767e
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Jun 5 18:13:08 2018 +0100
Remove data and maxlen fields from PktIn.
These were only used in the rdpkt coroutines, during construction of
the incoming packet; once it's complete, they're never touched again.
So really they should have been fields in the rdpkt coroutines' state
- and now they are.
The new memory allocation strategy for incoming packets is to defer
creation of the returned pktin structure until we know how big its
data buffer will really need to be, and then use snew_plus to make the
PktIn and the payload block in the same allocation.
When we have to read and keep some amount of the packet before
allocating the returned structure, we do it by having a persistent
buffer in the rdpkt state, which is retained for the whole connection
and only freed once in ssh_free.
ssh.c | 233 ++++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 134 insertions(+), 99 deletions(-)
commit 8c4680a97264258e1412213a65a7e3db0eda2040
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=8c4680a97264258e1412213a65a7e3db0eda2040;hp=ea04bf3da98173b22325dee30acca9146cc24851
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Jun 6 07:17:32 2018 +0100
Replace PktOut body pointer with a prefix length.
The body pointer was used after encryption to mark the start of the
fully wire-ready packet by ssh2_pkt_construct, and before encryption
by the log_outgoing_packet functions. Now the former returns a nice
modern ptrlen (it never really needed to store the pointer _in_ the
packet structure anyway), and the latter uses an integer 'prefix'
field, which isn't very different in concept but saves effort on
reallocs.
ssh.c | 75 +++++++++++++++++++++++++++----------------------------------------
1 file changed, 30 insertions(+), 45 deletions(-)
commit eb5bc3191151638bb800d582701a524dd095e411
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=eb5bc3191151638bb800d582701a524dd095e411;hp=8c4680a97264258e1412213a65a7e3db0eda2040
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Jun 5 23:02:31 2018 +0100
Make PktIn contain its own PacketQueueNode.
This saves a malloc and free every time we add or remove a packet from
a packet queue - it can now be done by pure pointer-shuffling instead
of allocating a separate list node structure.
ssh.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
commit 0df6303bb5f2aea6bec6bcc1454bd0971c0358e4
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=0df6303bb5f2aea6bec6bcc1454bd0971c0358e4;hp=eb5bc3191151638bb800d582701a524dd095e411
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Jun 6 20:05:13 2018 +0100
Fix a valgrind error.
rsa_ssh1_fingerprint will look at the input key's comment field, which
I forgot to initialise to anything, even the NULL it should be.
ssh.c | 2 ++
1 file changed, 2 insertions(+)
More information about the tartarus-commits
mailing list