diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-18 15:06:43 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-18 15:06:43 +0000 |
commit | 479744b146382c4a3cecf55241d6c3126eb49bdf (patch) | |
tree | 311febbcdd6554358414f1698ab04d93df357e41 /libssh/keyfiles.c | |
parent | a58b7b93de0d904286632804f01647fdeba47f98 (diff) | |
download | libssh-479744b146382c4a3cecf55241d6c3126eb49bdf.tar.gz libssh-479744b146382c4a3cecf55241d6c3126eb49bdf.tar.xz libssh-479744b146382c4a3cecf55241d6c3126eb49bdf.zip |
Add more error checks to asn1_get_int().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@551 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r-- | libssh/keyfiles.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index c6c9caed..b8ebe025 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -118,19 +118,29 @@ static u32 asn1_get_len(BUFFER *buffer) { } static STRING *asn1_get_int(BUFFER *buffer) { - STRING *ret; + STRING *str; unsigned char type; u32 size; - if (!buffer_get_data(buffer,&type,1) || type != ASN1_INTEGER) + if (buffer_get_data(buffer, &type, 1) == 0 || type != ASN1_INTEGER) { return NULL; - size=asn1_get_len(buffer); - if (!size) + } + size = asn1_get_len(buffer); + if (size == 0) { return NULL; - ret=string_new(size); - if (!buffer_get_data(buffer,ret->string,size)) + } + + str = string_new(size); + if (str == NULL) { return NULL; - return ret; + } + + if (buffer_get_data(buffer, str->string, size) == 0) { + string_free(str); + return NULL; + } + + return str; } static int asn1_check_sequence(BUFFER *buffer) { |