From: Guus Sliepen Date: Sun, 11 Jan 2015 00:52:37 +0000 (+0100) Subject: Fix segfault when sptps_test cannot open the key files. X-Git-Tag: release-1.1pre12~218 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=545ecb339654573b3ee91bffb45c8282154885c6;p=tinc Fix segfault when sptps_test cannot open the key files. --- diff --git a/src/sptps_test.c b/src/sptps_test.c index 95bfda86..38c2c08e 100644 --- a/src/sptps_test.c +++ b/src/sptps_test.c @@ -271,11 +271,19 @@ int main(int argc, char *argv[]) { crypto_init(); FILE *fp = fopen(argv[1], "r"); + if(!fp) { + fprintf(stderr, "Could not open %s: %s\n", argv[1], strerror(errno)); + return 1; + } if(!(mykey = ecdsa_read_pem_private_key(fp))) return 1; fclose(fp); fp = fopen(argv[2], "r"); + if(!fp) { + fprintf(stderr, "Could not open %s: %s\n", argv[2], strerror(errno)); + return 1; + } if(!(hiskey = ecdsa_read_pem_public_key(fp))) return 1; fclose(fp);