comparison signkey.c @ 1362:74a22c562cdf fuzz

Fix null pointer dereference found by libfuzzer
author Matt Johnston <matt@ucc.asn.au>
date Sun, 21 May 2017 18:53:09 +0800
parents 750ec4ec4cbe
children ddfcadca3c4c
comparison
equal deleted inserted replaced
1361:f9f930e1a516 1362:74a22c562cdf
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
292 } 293 }
293 #endif 294 #endif
294 #if DROPBEAR_ECDSA 295 #if DROPBEAR_ECDSA
295 if (signkey_is_ecdsa(type)) { 296 if (signkey_is_ecdsa(type)) {
296 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); 297 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
297 if (eck) { 298 if (eck && *eck) {
298 buf_put_ecdsa_pub_key(pubkeys, *eck); 299 buf_put_ecdsa_pub_key(pubkeys, *eck);
299 } 300 }
300 } 301 }
301 #endif 302 #endif
302 if (pubkeys->len == 0) { 303 if (pubkeys->len == 0) {
329 } 330 }
330 #endif 331 #endif
331 #if DROPBEAR_ECDSA 332 #if DROPBEAR_ECDSA
332 if (signkey_is_ecdsa(type)) { 333 if (signkey_is_ecdsa(type)) {
333 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); 334 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
334 if (eck) { 335 if (eck && *eck) {
335 buf_put_ecdsa_priv_key(buf, *eck); 336 buf_put_ecdsa_priv_key(buf, *eck);
336 TRACE(("leave buf_put_priv_key: ecdsa done")) 337 TRACE(("leave buf_put_priv_key: ecdsa done"))
337 return; 338 return;
338 } 339 }
339 } 340 }
493 } 494 }
494 #endif 495 #endif
495 #if DROPBEAR_ECDSA 496 #if DROPBEAR_ECDSA
496 if (signkey_is_ecdsa(type)) { 497 if (signkey_is_ecdsa(type)) {
497 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type); 498 ecc_key **eck = (ecc_key**)signkey_key_ptr(key, type);
498 if (eck) { 499 if (eck && *eck) {
499 buf_put_ecdsa_sign(sigblob, *eck, data_buf); 500 buf_put_ecdsa_sign(sigblob, *eck, data_buf);
500 } 501 }
501 } 502 }
502 #endif 503 #endif
503 if (sigblob->len == 0) { 504 if (sigblob->len == 0) {