mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2026-02-04 13:21:34 +00:00
Fix GH-37: decryption of an encrypted empty string returns false
Closes GH-50
This commit is contained in:
parent
d3bbfee186
commit
cab4eeb317
4 changed files with 34 additions and 5 deletions
1
NEWS.md
1
NEWS.md
|
|
@ -4,6 +4,7 @@ List of all features for the release
|
||||||
|
|
||||||
## X.Y.Z
|
## X.Y.Z
|
||||||
- The deletekey `allow_secret` made optional again
|
- The deletekey `allow_secret` made optional again
|
||||||
|
- Fixed GH-37: `gnupg_decrypt()` returns false when decrypting an encrypted empty string
|
||||||
|
|
||||||
## 1.5.1
|
## 1.5.1
|
||||||
- Fixed compilation with PHP 8.1
|
- Fixed compilation with PHP 8.1
|
||||||
|
|
|
||||||
10
gnupg.c
10
gnupg.c
|
|
@ -1705,11 +1705,13 @@ PHP_FUNCTION(gnupg_decrypt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
userret = gpgme_data_release_and_get_mem(out, &ret_size);
|
userret = gpgme_data_release_and_get_mem(out, &ret_size);
|
||||||
|
|
||||||
gpgme_data_release(in);
|
gpgme_data_release(in);
|
||||||
PHPC_CSTRL_RETVAL(userret, ret_size);
|
if (userret != NULL) {
|
||||||
free(userret);
|
PHPC_CSTRL_RETVAL(userret, ret_size);
|
||||||
if (ret_size < 1) {
|
free(userret);
|
||||||
RETVAL_FALSE;
|
} else {
|
||||||
|
PHPC_CSTR_EMPTY_RETVAL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
|
||||||
2
phpc
2
phpc
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4521e6b11a3e578600772e4d2628a5f414fb60af
|
Subproject commit 40078fd256965d76cddc060b7dd2e7849444f047
|
||||||
26
tests/gnupg_oo_encrypt_empty_str.phpt
Normal file
26
tests/gnupg_oo_encrypt_empty_str.phpt
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
--TEST--
|
||||||
|
encrypt and decrypt a text
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
|
$gpg->addencryptkey($fingerprint);
|
||||||
|
$enc = $gpg->encrypt("");
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$gpg->adddecryptkey($fingerprint, $passphrase);
|
||||||
|
$ret = $gpg->decrypt($enc);
|
||||||
|
var_dump($ret);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
string(0) ""
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue