Browse Source

Avoid null pointer dereferences when no username/password specified.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
d6f9152bfa
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/net/tcp/iscsi.c

+ 6
- 3
src/net/tcp/iscsi.c View File

403
 		used += ssnprintf ( data + used, len - used, "CHAP_A=5%c", 0 );
403
 		used += ssnprintf ( data + used, len - used, "CHAP_A=5%c", 0 );
404
 	}
404
 	}
405
 	
405
 	
406
-	if ( iscsi->status & ISCSI_STATUS_STRINGS_CHAP_RESPONSE ) {
406
+	if ( ( iscsi->status & ISCSI_STATUS_STRINGS_CHAP_RESPONSE ) &&
407
+	     iscsi->username ) {
407
 		used += ssnprintf ( data + used, len - used,
408
 		used += ssnprintf ( data + used, len - used,
408
 				    "CHAP_N=%s%cCHAP_R=0x",
409
 				    "CHAP_N=%s%cCHAP_R=0x",
409
 				    iscsi->username, 0 );
410
 				    iscsi->username, 0 );
572
 	 * challenge.
573
 	 * challenge.
573
 	 */
574
 	 */
574
 	chap_set_identifier ( &iscsi->chap, identifier );
575
 	chap_set_identifier ( &iscsi->chap, identifier );
575
-	chap_update ( &iscsi->chap, iscsi->password,
576
-		      strlen ( iscsi->password ) );
576
+	if ( iscsi->password ) {
577
+		chap_update ( &iscsi->chap, iscsi->password,
578
+			      strlen ( iscsi->password ) );
579
+	}
577
 }
580
 }
578
 
581
 
579
 /**
582
 /**

Loading…
Cancel
Save