1
1

Add error checking for make_rsa1_string().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@423 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
Andreas Schneider 2009-04-07 19:50:41 +00:00
родитель 586ed9103f
Коммит c4f65cb5dd

Просмотреть файл

@ -442,17 +442,34 @@ int verify_existing_algo(int algo, const char *name){
/* makes a STRING contating 3 strings : ssh-rsa1,e and n */ /* makes a STRING contating 3 strings : ssh-rsa1,e and n */
/* this is a public key in openssh's format */ /* this is a public key in openssh's format */
static STRING *make_rsa1_string(STRING *e, STRING *n){ static STRING *make_rsa1_string(STRING *e, STRING *n){
BUFFER *buffer=buffer_new(); BUFFER *buffer = NULL;
STRING *rsa=string_from_char("ssh-rsa1"); STRING *rsa = NULL;
STRING *ret; STRING *ret = NULL;
buffer_add_ssh_string(buffer,rsa);
free(rsa); buffer = buffer_new();
buffer_add_ssh_string(buffer,e); rsa = string_from_char("ssh-rsa1");
buffer_add_ssh_string(buffer,n);
ret=string_new(buffer_get_len(buffer)); if (buffer_add_ssh_string(buffer, rsa) < 0) {
string_fill(ret,buffer_get(buffer),buffer_get_len(buffer)); goto error;
buffer_free(buffer); }
return ret; if (buffer_add_ssh_string(buffer, e) < 0) {
goto error;
}
if (buffer_add_ssh_string(buffer, n) < 0) {
goto error;
}
ret = string_new(buffer_get_len(buffer));
if (ret == NULL) {
goto error;
}
string_fill(ret, buffer_get(buffer), buffer_get_len(buffer));
error:
buffer_free(buffer);
string_free(rsa);
return ret;
} }
/* TODO FIXME add return value and error checking in callers */ /* TODO FIXME add return value and error checking in callers */