mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 02:38:09 +09:00
Use POSIX return values and check them!
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@558 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -70,7 +70,7 @@ static int load_iv(char *header, unsigned char *iv, int iv_len) {
|
|||||||
else if ((header[2*i] >= 'a') && (header[2*i] <= 'f'))
|
else if ((header[2*i] >= 'a') && (header[2*i] <= 'f'))
|
||||||
j = header[2*i] - 'a' + 10;
|
j = header[2*i] - 'a' + 10;
|
||||||
else
|
else
|
||||||
return 0;
|
return -1;
|
||||||
if ((header[2*i+1] >= '0') && (header[2*i+1] <= '9'))
|
if ((header[2*i+1] >= '0') && (header[2*i+1] <= '9'))
|
||||||
k = header[2*i+1] - '0';
|
k = header[2*i+1] - '0';
|
||||||
else if ((header[2*i+1] >= 'A') && (header[2*i+1] <= 'F'))
|
else if ((header[2*i+1] >= 'A') && (header[2*i+1] <= 'F'))
|
||||||
@@ -78,10 +78,10 @@ static int load_iv(char *header, unsigned char *iv, int iv_len) {
|
|||||||
else if ((header[2*i+1] >= 'a') && (header[2*i+1] <= 'f'))
|
else if ((header[2*i+1] >= 'a') && (header[2*i+1] <= 'f'))
|
||||||
k = header[2*i+1] - 'a' + 10;
|
k = header[2*i+1] - 'a' + 10;
|
||||||
else
|
else
|
||||||
return 0;
|
return -1;
|
||||||
iv[i] = (j << 4) + k;
|
iv[i] = (j << 4) + k;
|
||||||
}
|
}
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 char_to_u32(unsigned char *data, u32 size) {
|
static u32 char_to_u32(unsigned char *data, u32 size) {
|
||||||
@@ -314,15 +314,16 @@ static int privatekey_dek_header(char *header, unsigned int header_len,
|
|||||||
*mode = GCRY_CIPHER_MODE_CBC;
|
*mode = GCRY_CIPHER_MODE_CBC;
|
||||||
*key_len = 32;
|
*key_len = 32;
|
||||||
*iv_len = 16;
|
*iv_len = 16;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
*iv = malloc(*iv_len);
|
*iv = malloc(*iv_len);
|
||||||
if (*iv == NULL) {
|
if (*iv == NULL) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
load_iv(header + iv_pos, *iv, *iv_len);
|
|
||||||
return 1;
|
return load_iv(header + iv_pos, *iv, *iv_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BUFFER *privatekey_file_to_buffer(FILE *fp, int type,
|
static BUFFER *privatekey_file_to_buffer(FILE *fp, int type,
|
||||||
@@ -364,8 +365,8 @@ static BUFFER *privatekey_file_to_buffer(FILE *fp, int type,
|
|||||||
len = read_line(buf, MAXLINESIZE, fp);
|
len = read_line(buf, MAXLINESIZE, fp);
|
||||||
if (len > 10 && !strncmp("DEK-Info: ", buf, 10))
|
if (len > 10 && !strncmp("DEK-Info: ", buf, 10))
|
||||||
{
|
{
|
||||||
if (!privatekey_dek_header(buf + 10, len - 10, &algo, &mode, &key_len,
|
if ((privatekey_dek_header(buf + 10, len - 10, &algo, &mode, &key_len,
|
||||||
&iv, &iv_len)
|
&iv, &iv_len) < 0)
|
||||||
|| read_line(buf, MAXLINESIZE, fp))
|
|| read_line(buf, MAXLINESIZE, fp))
|
||||||
{
|
{
|
||||||
buffer_free(buffer);
|
buffer_free(buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user