comparison signkey.c @ 1423:c1c3d5943bfc

Fix null pointer dereference found by libfuzzer
author Matt Johnston <matt@ucc.asn.au>
date Sun, 21 May 2017 18:53:09 +0800
parents c721e8c42d2a
children 8a4b8f026de6
comparison
equal deleted inserted replaced
1422:4cebe907dfd0 1423:c1c3d5943bfc
100 TRACE(("signkey_type_from_name unexpected key type.")) 100 TRACE(("signkey_type_from_name unexpected key type."))
101 101
102 return DROPBEAR_SIGNKEY_NONE; 102 return DROPBEAR_SIGNKEY_NONE;
103 } 103 }
104 104
105 /* Returns a pointer to the key part specific to "type" */ 105 /* Returns a pointer to the key part specific to "type".
106 Be sure to check both (ret != NULL) and (*ret != NULL) */
106 void ** 107 void **
107 signkey_key_ptr(sign_key *key, enum signkey_type type) { 108 signkey_key_ptr(sign_key *key, enum signkey_type type) {
108 switch (type) { 109 switch (type) {
109 #if DROPBEAR_ECDSA 110 #if DROPBEAR_ECDSA
110 #if DROPBEAR_ECC_256 111 #if DROPBEAR_ECC_256
295 } 296 }
296 #endif 297 #endif
297 #if DROPBEAR_ECDSA 298 #if DROPBEAR_ECDSA
298 if (signkey_is_ecdsa(type)) { 299 if (signkey_is_ecdsa(type)) {
299 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); 300 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
300 if (eck) { 301 if (eck && *eck) {
301 buf_put_ecdsa_pub_key(pubkeys, *eck); 302 buf_put_ecdsa_pub_key(pubkeys, *eck);
302 } 303 }
303 } 304 }
304 #endif 305 #endif
305 if (pubkeys->len == 0) { 306 if (pubkeys->len == 0) {
332 } 333 }
333 #endif 334 #endif
334 #if DROPBEAR_ECDSA 335 #if DROPBEAR_ECDSA
335 if (signkey_is_ecdsa(type)) { 336 if (signkey_is_ecdsa(type)) {
336 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); 337 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
337 if (eck) { 338 if (eck && *eck) {
338 buf_put_ecdsa_priv_key(buf, *eck); 339 buf_put_ecdsa_priv_key(buf, *eck);
339 TRACE(("leave buf_put_priv_key: ecdsa done")) 340 TRACE(("leave buf_put_priv_key: ecdsa done"))
340 return; 341 return;
341 } 342 }
342 } 343 }
496 } 497 }
497 #endif 498 #endif
498 #if DROPBEAR_ECDSA 499 #if DROPBEAR_ECDSA
499 if (signkey_is_ecdsa(type)) { 500 if (signkey_is_ecdsa(type)) {
500 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); 501 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
501 if (eck) { 502 if (eck && *eck) {
502 buf_put_ecdsa_sign(sigblob, *eck, data_buf); 503 buf_put_ecdsa_sign(sigblob, *eck, data_buf);
503 } 504 }
504 } 505 }
505 #endif 506 #endif
506 if (sigblob->len == 0) { 507 if (sigblob->len == 0) {