simon-git: putty (master): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Sun May 27 15:33:29 BST 2018
TL;DR:
0fc2d3b Invent a struct type for polymorphic SSH key data.
5129c40 Modernise the Socket/Plug vtable system.
f6d04ef Fix minor memory leak in Pageant key removal.
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-05-27 15:33:29
commit 0fc2d3b455eac062db03ea9ad0213806dfaa185e
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=0fc2d3b455eac062db03ea9ad0213806dfaa185e;hp=9375f594c22617ac543aa04b0f46e8ee4a36f5c0
Author: Simon Tatham <anakin at pobox.com>
Date: Sun May 27 08:32:21 2018 +0100
Invent a struct type for polymorphic SSH key data.
During last week's work, I made a mistake in which I got the arguments
backwards in one of the key-blob-generating functions - mistakenly
swapped the 'void *' key instance with the 'BinarySink *' output
destination - and I didn't spot the mistake until run time, because in
C you can implicitly convert both to and from void * and so there was
no compile-time failure of type checking.
Now that I've introduced the FROMFIELD macro that downcasts a pointer
to one field of a structure to retrieve a pointer to the whole
structure, I think I might start using that more widely to indicate
this kind of polymorphic subtyping. So now all the public-key
functions in the struct ssh_signkey vtable handle their data instance
in the form of a pointer to a subfield of a new zero-sized structure
type 'ssh_key', which outside the key implementations indicates 'this
is some kind of key instance but it could be of any type'; they
downcast that pointer internally using FROMFIELD in place of the
previous ordinary C cast, and return one by returning &foo->sshk for
whatever foo they've just made up.
The sshk member is not at the beginning of the structure, which means
all those FROMFIELDs and &key->sshk are actually adding and
subtracting an offset. Of course I could have put the member at the
start anyway, but I had the idea that it's actually a feature _not_ to
have the two types start at the same address, because it means you
should notice earlier rather than later if you absentmindedly cast
from one to the other directly rather than by the approved method (in
particular, if you accidentally assign one through a void * and back
without even _noticing_ you perpetrated a cast). In particular, this
enforces that you can't sfree() the thing even once without realising
you should instead of called the right freekey function. (I found
several bugs by this method during initial testing, so I think it's
already proved its worth!)
While I'm here, I've also renamed the vtable structure ssh_signkey to
ssh_keyalg, because it was a confusing name anyway - it describes the
_algorithm_ for handling all keys of that type, not a specific key. So
ssh_keyalg is the collection of code, and ssh_key is one instance of
the data it handles.
cmdgen.c | 10 ++---
import.c | 10 ++---
ssh.c | 26 +++++------
ssh.h | 90 ++++++++++++++++++++------------------
sshdss.c | 72 +++++++++++++++---------------
sshecc.c | 128 +++++++++++++++++++++++++++---------------------------
sshpubk.c | 12 ++---
sshrsa.c | 87 ++++++++++++++++++-------------------
windows/winpgen.c | 10 ++---
9 files changed, 225 insertions(+), 220 deletions(-)
commit 5129c40beabcefd7c41453e70ca9551178547672
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=5129c40beabcefd7c41453e70ca9551178547672;hp=0fc2d3b455eac062db03ea9ad0213806dfaa185e
Author: Simon Tatham <anakin at pobox.com>
Date: Sun May 27 09:29:33 2018 +0100
Modernise the Socket/Plug vtable system.
Now I've got FROMFIELD, I can rework it so that structures providing
an implementation of the Socket or Plug trait no longer have to have
the vtable pointer as the very first thing in the structure. In
particular, this means that the ProxySocket structure can now directly
implement _both_ the Socket and Plug traits, which is always
_logically_ how it's worked, but previously it had to be implemented
via two separate structs linked to each other.
cproxy.c | 4 +-
defs.h | 14 ++++
errsock.c | 64 ++++++++---------
network.h | 9 +--
nocproxy.c | 4 +-
pageant.c | 65 +++++++++--------
pageant.h | 4 +-
portfwd.c | 66 ++++++++---------
proxy.c | 108 +++++++++++++---------------
proxy.h | 34 ++++-----
raw.c | 30 ++++----
rlogin.c | 30 ++++----
ssh.c | 40 +++++------
ssh.h | 5 +-
sshshare.c | 99 ++++++++++++++------------
telnet.c | 32 ++++-----
unix/unix.h | 2 +-
unix/uxnet.c | 191 ++++++++++++++++++++++++-------------------------
unix/uxpgnt.c | 27 +++----
unix/uxproxy.c | 87 +++++++++++------------
windows/winhsock.c | 195 +++++++++++++++++++++++++-------------------------
windows/winnet.c | 204 ++++++++++++++++++++++-------------------------------
windows/winnps.c | 62 ++++++++--------
x11fwd.c | 39 +++++-----
24 files changed, 678 insertions(+), 737 deletions(-)
commit f6d04ef1c4dfec659fb3b548d70d921909b19f02
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=f6d04ef1c4dfec659fb3b548d70d921909b19f02;hp=5129c40beabcefd7c41453e70ca9551178547672
Author: Simon Tatham <anakin at pobox.com>
Date: Sun May 27 09:29:33 2018 +0100
Fix minor memory leak in Pageant key removal.
It wasn't freeing the key comment along with the key data, probably
because I originally based the code on the SSH-1 analogue and forgot
that freersakey() *does* free the comment.
pageant.c | 2 ++
1 file changed, 2 insertions(+)
More information about the tartarus-commits
mailing list