Commit Graph

16 Commits

Author SHA1 Message Date
Nicolas Williams
b93129f83d roken: Fix FD and memory leaks in rk_undumptext() 2023-01-04 00:43:35 -06:00
Nicolas Williams
319793b30b roken: Fix leak in new undump_not_file() 2023-01-04 00:43:35 -06:00
Nicolas Williams
8b6926f4c0 roken: Add rk_undumptext() and support ttys and such
Add rk_undumptext(), which NUL-terminates the contents it reads.

rk_undumptext(), and now also rk_undumpdata(), can read from regular and
non-regular files (e.g., ttys, pipes, devices, but -on Windows- not
sockets).

This means that `asn1_print` can now read from `/dev/stdin`, which can
be a pipe.

There's a way to set a limit on how much to read from non-regular files,
and that limit defaults to 10MB.

At any rate, the rk_dumpdata(), rk_undumpdata(), and rk_undumptext() functions
really do not belong in lib/roken but in lib/base.  There are other utility
functions in lib/roken that don't belong there too.  A rationalization of the
split between lib/roken and lib/base is overdue.  And while we're at it -lest I
forget- it'd be nice to move all the krb5_storage functions out of lib/krb5 and
into lib/base, as those could come in handy for, e.g., implementing OpenSSH
style certificates and other things outside the krb5 universe.
2022-12-21 22:06:15 -06:00
Nicolas Williams
ca2467a4c4 roken: Do not use net_read() for regular files!
The bug fixed herein almost certainly means that PKINIT was never
working on Windows, since lib/hx509 uses rk_undumpdata() to read regular
files containing certificates and keys, but then since rk_undumpdata()
was using net_read(), that can't have worked.  On Windows net_read()
insists on the FD being a socket, and because of winsock, the namespaces
of socket and file descriptors on Windows are distinct.
2022-12-20 22:19:39 -06:00
Jeffrey Altman
2f62c7c77e roken: rk_undumpdata free allocation on error
Do not return allocated memory and an error code.
Free it instead so as to avoid memory leaks.

Change-Id: I47d42be0f6bc52062c57c00c37b665ee2f2811ce
2016-11-19 02:08:58 -05:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Asanka Herath
d00f9984a5 Make roken build on windows
Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
2009-11-24 21:42:02 -08:00
Love Hörnquist Åstrand
0d31d3d686 drop rcsid
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24356 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:30:37 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
405983ffb9 fix warning
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23412 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-26 18:34:23 +00:00
Love Hörnquist Åstrand
13ebabfab7 add rk_undumpdata
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23391 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-07-26 18:24:54 +00:00
Love Hörnquist Åstrand
5cd0815781 use "roken.h" consitantly
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21005 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-08 01:54:35 +00:00
Love Hörnquist Åstrand
9df9f6a9da revert 21003
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21004 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-08 01:53:10 +00:00
Love Hörnquist Åstrand
12df8538af use "roken.h" consitantly
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21003 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-08 01:42:05 +00:00
Love Hörnquist Åstrand
47be0b2203 Add rk_dumpdata() that write a chunk of data into a file for later
processing by some other tool (like asn1_print).


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16089 ec53bebd-3082-4978-b11e-865c3cabbd6b
2005-09-22 23:51:35 +00:00