summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-08-19 11:35:20 +0400
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-08-19 11:35:20 +0400
commit5c37365cca259780a3d73f98637fc9f6ccfcbc23 (patch)
tree7d55c510b79063eb68f513bd0503c76662f45762
parenttests/tunnel.scm ("call-with-ssh-forward"): Use 'poll' procedure (diff)
downloadguile-ssh-5c37365cca259780a3d73f98637fc9f6ccfcbc23.tar.gz
libguile-ssh/key-type.c (free_key_smob): Bugfix: Check smob type
* libguile-ssh/key-type.c (free_key_smob): Bugfix: Check if the smob is already freed, don't try to free it once more. * tests/common.scm (test-begin-with-log): Set log verbosity to the highest level by default. * tests/key.scm: Perform test with logging.
-rw-r--r--libguile-ssh/key-type.c10
-rw-r--r--tests/common.scm1
-rw-r--r--tests/key.scm16
3 files changed, 18 insertions, 9 deletions
diff --git a/libguile-ssh/key-type.c b/libguile-ssh/key-type.c
index 46c2d71..8bb8f28 100644
--- a/libguile-ssh/key-type.c
+++ b/libguile-ssh/key-type.c
@@ -57,7 +57,15 @@ mark_key_smob (SCM key_smob)
size_t
free_key_smob (SCM arg1)
{
- struct key_data *data = _scm_to_key_data (arg1);
+ struct key_data *data;
+ if (! SCM_SMOB_PREDICATE (key_tag, arg1))
+ {
+ _ssh_log (SSH_LOG_FUNCTIONS, "free_key_smob", "%s", "already freed");
+ return 0;
+ }
+
+ data = _scm_to_key_data (arg1);
+
if (scm_is_false (data->parent))
{
/* It's safe to free the key only if it was not derived from some other
diff --git a/tests/common.scm b/tests/common.scm
index 77034ea..c5dac55 100644
--- a/tests/common.scm
+++ b/tests/common.scm
@@ -469,6 +469,7 @@ printer."
(setup-error-logging! errors-log-file)))
(define (test-begin-with-log test-name)
+ (set-log-verbosity! 'functions)
(test-begin test-name)
(setup-test-suite-logging! test-name))
diff --git a/tests/key.scm b/tests/key.scm
index cfbed1a..19e0ca0 100644
--- a/tests/key.scm
+++ b/tests/key.scm
@@ -33,15 +33,15 @@
(or (not %openssl?)
test))
-(test-begin "key")
+(test-begin-with-log "key")
-(test-assert "private-key-from-file"
+(test-assert-with-log "private-key-from-file"
(and (private-key-from-file %rsakey)
(private-key-from-file %dsakey)
(when-openssl
(private-key-from-file %ecdsakey))))
-(test-assert "public-key-from-file"
+(test-assert-with-log "public-key-from-file"
(and (public-key-from-file %rsakey-pub)
(public-key-from-file %dsakey-pub)
(when-openssl
@@ -72,7 +72,7 @@
(not (private-key? *rsa-pub-key*))
(not (private-key? "not a key"))))
-(test-assert "public-key?"
+(test-assert-with-log "public-key?"
(and (public-key? *rsa-pub-key*)
;; XXX: Currently a SSH key that has been read from a file
@@ -81,20 +81,20 @@
(not (public-key? "not a key"))))
-(test-assert "private-key->public-key"
+(test-assert-with-log "private-key->public-key"
(and (private-key->public-key *rsa-key*)
(private-key->public-key *dsa-key*)
(when-openssl
(private-key->public-key *ecdsa-key*))))
-(test-assert "get-key-type"
+(test-assert-with-log "get-key-type"
(and (eq? 'rsa (get-key-type *rsa-key*))
(eq? 'dss (get-key-type *dsa-key*))
(when-openssl
(eq? 'ecdsa (get-key-type *ecdsa-key*)))))
-(test-assert "private-key-to-file"
+(test-assert-with-log "private-key-to-file"
(when-openssl
(let ((file-name "./tmp-rsa-key"))
(private-key-to-file *rsa-key* file-name)
@@ -142,7 +142,7 @@
%ecdsakey-pub-string))
-(test-assert "make-keypair"
+(test-assert-with-log "make-keypair"
(and (let ((key (make-keypair 'rsa 1024)))
(and (key? key)
(eq? (get-key-type key) 'rsa)))