chunk: Use dynamically allocated buffer in chunk_from_fd()
authorMartin Willi <martin@revosec.ch>
Thu, 21 Nov 2013 11:19:20 +0000 (12:19 +0100)
committerMartin Willi <martin@revosec.ch>
Thu, 23 Jan 2014 14:55:32 +0000 (15:55 +0100)
commit1c4a3459f72da4391c1befe22e62356d838af46d
treea60e5be4cf8c95c05b891f84df5ffa1069ec65ef
parent595b6d9a828538072dcf65c276b848a02698fdfe
chunk: Use dynamically allocated buffer in chunk_from_fd()

When acting on files, we can use fstat() to estimate the buffer size. On
non-file FDs, we dynamically increase an allocated buffer.

Additionally we slightly change the function signature to properly handle
zero-length files and add appropriate unit tests.
src/libstrongswan/tests/suites/test_chunk.c
src/libstrongswan/utils/chunk.c
src/libstrongswan/utils/chunk.h
src/pki/commands/issue.c
src/pki/commands/keyid.c
src/pki/commands/print.c
src/pki/commands/pub.c
src/pki/commands/req.c
src/pki/commands/self.c
src/pki/commands/verify.c