From c0c61a5eece80fb5cbc5388e84f5a0a616606f3c Mon Sep 17 00:00:00 2001 From: Damien Stuart Date: Fri, 2 Jan 2009 14:30:36 +0000 Subject: [PATCH] Minor tweaks, and fixed one potential memory allocation issue discovered with valgrind. git-svn-id: file:///home/mbr/svn/fwknop/trunk@35 510a4753-2344-4c79-9c09-4d669213fbeb --- doc/Makefile.am | 13 ++----------- doc/libfko.texi | 2 +- fko/fko_encryption.c | 2 +- fko/sha.h | 14 ++++++++++---- fko/sha256.c | 4 ---- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 7a9745c0..172b7f46 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,13 +1,4 @@ +CLEANFILES = libfko.info + info_TEXINFOS = libfko.texi libfko_TEXINFOS = gpl-2.0.texi - -SUFFIXES = .html - -html_docs = libfko.html - -.texi.html: - $(MAKEINFO) --html $< - -.PHONY: html -html: version.texi $(html_docs) - diff --git a/doc/libfko.texi b/doc/libfko.texi index dec8e21a..eabdf0c9 100644 --- a/doc/libfko.texi +++ b/doc/libfko.texi @@ -363,7 +363,7 @@ is base64-encoded before it is added to the @acronym{SPA} data. Currently, libfko support the same three message digests as fwknop. These are (in order of strength): -@deftypevar enum fko_digest_type_t +@deftypevar int fko_digest_type_t @table @code @item FKO_DIGEST_MD5 @item FKO_DIGEST_SHA1 diff --git a/fko/fko_encryption.c b/fko/fko_encryption.c index 4983e8e5..8349ab60 100644 --- a/fko/fko_encryption.c +++ b/fko/fko_encryption.c @@ -117,7 +117,7 @@ fko_encrypt_spa_data(fko_ctx_t ctx, const char *enc_key) /* Now make a bucket for the base64-encoded version and populate it. */ - b64cipher = malloc(((cipher_len / 3) * 4) + 4); + b64cipher = malloc(((cipher_len / 3) * 4) + 8); if(b64cipher == NULL) return(FKO_ERROR_MEMORY_ALLOCATION); diff --git a/fko/sha.h b/fko/sha.h index b24c09ae..83ba8b3f 100644 --- a/fko/sha.h +++ b/fko/sha.h @@ -1,7 +1,7 @@ /* $Id$ ***************************************************************************** * - * File: sha256.h + * File: sha.h * * Purpose: Header for sha.c * @@ -25,12 +25,18 @@ * ***************************************************************************** */ -#ifndef SHA256_H -#define SHA256_H 1 +#ifndef SHA_H +#define SHA_H 1 #include #include "fko_common.h" +/* Truncate to 32 bits -- should be a null op on 32-bit machines +*/ +#ifndef TRUNC32 + #define TRUNC32(x) ((x) & 0xffffffffL) +#endif + /* This should be fine for most systems (hopefully). */ #define BYTEORDER __BYTE_ORDER @@ -59,4 +65,4 @@ void sha256_update(SHA_INFO *sha_info, uint8 *buffer, int count); void sha256_final(SHA_INFO *sha_info); void sha256_unpackdigest(uint8 digest[SHA256_DIGESTSIZE], SHA_INFO *sha_info); -#endif /* SHA256_H */ +#endif /* SHA_H */ diff --git a/fko/sha256.c b/fko/sha256.c index ec8f8f8a..af7a4534 100644 --- a/fko/sha256.c +++ b/fko/sha256.c @@ -27,10 +27,6 @@ */ #include "sha.h" -/* Truncate to 32 bits -- should be a null op on 32-bit machines -*/ -#define TRUNC32(x) ((x) & 0xffffffffL) - /* 32-bit rotate to the RIGHT */ #define ROT32(x,n) TRUNC32(((x >> n) | (x << (32 - n))))