File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,8 @@ impl PublicKey {
232232 /// Creates a public key directly from a slice
233233 #[ inline]
234234 pub fn from_slice ( data : & [ u8 ] ) -> Result < PublicKey , Error > {
235+ if data. is_empty ( ) { return Err ( Error :: InvalidPublicKey ) ; }
236+
235237 let mut pk = ffi:: PublicKey :: new ( ) ;
236238 unsafe {
237239 if ffi:: secp256k1_ec_pubkey_parse (
Original file line number Diff line number Diff line change @@ -247,6 +247,8 @@ impl Signature {
247247#[ inline]
248248 /// Converts a DER-encoded byte slice to a signature
249249 pub fn from_der ( data : & [ u8 ] ) -> Result < Signature , Error > {
250+ if data. is_empty ( ) { return Err ( Error :: InvalidSignature ) ; }
251+
250252 let mut ret = ffi:: Signature :: new ( ) ;
251253
252254 unsafe {
@@ -290,6 +292,8 @@ impl Signature {
290292 /// 2016. It should never be used in new applications. This library does not
291293 /// support serializing to this "format"
292294 pub fn from_der_lax ( data : & [ u8 ] ) -> Result < Signature , Error > {
295+ if data. is_empty ( ) { return Err ( Error :: InvalidSignature ) ; }
296+
293297 unsafe {
294298 let mut ret = ffi:: Signature :: new ( ) ;
295299 if ffi:: ecdsa_signature_parse_der_lax (
Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ impl RecoverableSignature {
5858 /// representation is nonstandard and defined by the libsecp256k1
5959 /// library.
6060 pub fn from_compact ( data : & [ u8 ] , recid : RecoveryId ) -> Result < RecoverableSignature , Error > {
61+ if data. is_empty ( ) { return Err ( Error :: InvalidSignature ) ; }
62+
6163 let mut ret = ffi:: RecoverableSignature :: new ( ) ;
6264
6365 unsafe {
You can’t perform that action at this time.
0 commit comments