summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Stöneberg <oliverst@online.de>2011-05-13 05:50:41 -0700
committerAndreas Schneider <asn@cryptomilk.org>2011-05-17 14:20:48 +0200
commit525324b2f9ee2bd9a39ba88267e76c88e7f58bd1 (patch)
treebf2cf28f8cc4ea3c3b6d7d04db7576ba74f4775c
parente3311d03dba7ae281597cf5de235bcefda44457c (diff)
downloadlibssh-525324b2f9ee2bd9a39ba88267e76c88e7f58bd1.tar.gz
libssh-525324b2f9ee2bd9a39ba88267e76c88e7f58bd1.tar.xz
libssh-525324b2f9ee2bd9a39ba88267e76c88e7f58bd1.zip
examples: Use the right cleanup functions.
-rw-r--r--examples/authentication.c2
-rw-r--r--examples/knownhosts.c13
2 files changed, 9 insertions, 6 deletions
diff --git a/examples/authentication.c b/examples/authentication.c
index 0f236326..c233e300 100644
--- a/examples/authentication.c
+++ b/examples/authentication.c
@@ -157,7 +157,7 @@ int authenticate_console(ssh_session session){
banner = ssh_get_issue_banner(session);
if (banner) {
printf("%s\n",banner);
- free(banner);
+ ssh_string_free_char(banner);
}
return rc;
diff --git a/examples/knownhosts.c b/examples/knownhosts.c
index 2797c3f2..37c0ba4e 100644
--- a/examples/knownhosts.c
+++ b/examples/knownhosts.c
@@ -48,7 +48,7 @@ int verify_knownhost(ssh_session session){
case SSH_SERVER_KNOWN_CHANGED:
fprintf(stderr,"Host key for server changed : server's one is now :\n");
ssh_print_hexa("Public key hash",hash, hlen);
- free(hash);
+ ssh_clean_pubkey_hash(&hash);
fprintf(stderr,"For security reason, connection will be stopped\n");
return -1;
case SSH_SERVER_FOUND_OTHER:
@@ -65,20 +65,23 @@ int verify_knownhost(ssh_session session){
hexa = ssh_get_hexa(hash, hlen);
fprintf(stderr,"The server is unknown. Do you trust the host key ?\n");
fprintf(stderr, "Public key hash: %s\n", hexa);
- free(hexa);
+ ssh_string_free_char(hexa);
if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ ssh_clean_pubkey_hash(&hash);
return -1;
}
if(strncasecmp(buf,"yes",3)!=0){
+ ssh_clean_pubkey_hash(&hash);
return -1;
}
fprintf(stderr,"This new key will be written on disk for further usage. do you agree ?\n");
if (fgets(buf, sizeof(buf), stdin) == NULL) {
+ ssh_clean_pubkey_hash(&hash);
return -1;
}
if(strncasecmp(buf,"yes",3)==0){
if (ssh_write_knownhost(session) < 0) {
- free(hash);
+ ssh_clean_pubkey_hash(&hash);
fprintf(stderr, "error %s\n", strerror(errno));
return -1;
}
@@ -86,10 +89,10 @@ int verify_knownhost(ssh_session session){
break;
case SSH_SERVER_ERROR:
- free(hash);
+ ssh_clean_pubkey_hash(&hash);
fprintf(stderr,"%s",ssh_get_error(session));
return -1;
}
- free(hash);
+ ssh_clean_pubkey_hash(&hash);
return 0;
}