]> granicus.if.org Git - php/commitdiff
don't segfault if given invalid/empty private key
authorAntony Dovgal <tony2001@php.net>
Tue, 29 Jul 2008 11:18:40 +0000 (11:18 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 29 Jul 2008 11:18:40 +0000 (11:18 +0000)
ext/phar/util.c

index add7ce8d160741a2a49f2a5ff0d2ef566e7a93dc..909f4053aa84a9e2acae5458ce799988094984a1 100644 (file)
@@ -1902,6 +1902,13 @@ int phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signat
                        key = PEM_read_bio_PrivateKey(in, NULL,NULL, "");
 
                        BIO_free(in);
+                       if (!key) {
+                               if (error) {
+                                       spprintf(error, 0, "unable to process private key");
+                               }
+                               return FAILURE;
+                       }
+
                        siglen = EVP_PKEY_size(key);
                        sigbuf = emalloc(siglen + 1);