Parcourir la source

[block] Quell spurious Coverity size mismatch warning

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 7 ans
Parent
révision
e846bd22c3
1 fichiers modifiés avec 10 ajouts et 6 suppressions
  1. 10
    6
      src/core/sanboot.c

+ 10
- 6
src/core/sanboot.c Voir le fichier

@@ -466,7 +466,10 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
466 466
 		.type = ISO9660_TYPE_PRIMARY,
467 467
 		.id = ISO9660_ID,
468 468
 	};
469
-	struct iso9660_primary_descriptor *primary;
469
+	union {
470
+		struct iso9660_primary_descriptor primary;
471
+		char bytes[ISO9660_BLKSIZE];
472
+	} *scratch;
470 473
 	unsigned int blksize;
471 474
 	unsigned int blksize_shift;
472 475
 	unsigned int lba;
@@ -489,14 +492,14 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
489 492
 	count = ( 1 << blksize_shift );
490 493
 
491 494
 	/* Allocate scratch area */
492
-	primary = malloc ( ISO9660_BLKSIZE );
493
-	if ( ! primary ) {
495
+	scratch = malloc ( ISO9660_BLKSIZE );
496
+	if ( ! scratch ) {
494 497
 		rc = -ENOMEM;
495 498
 		goto err_alloc;
496 499
 	}
497 500
 
498 501
 	/* Read primary volume descriptor */
499
-	if ( ( rc = sandev_rw ( sandev, lba, count, virt_to_user ( primary ),
502
+	if ( ( rc = sandev_rw ( sandev, lba, count, virt_to_user ( scratch ),
500 503
 				block_read ) ) != 0 ) {
501 504
 		DBGC ( sandev, "SAN %#02x could not read ISO9660 primary"
502 505
 		       "volume descriptor: %s\n",
@@ -505,7 +508,8 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
505 508
 	}
506 509
 
507 510
 	/* Configure as CD-ROM if applicable */
508
-	if ( memcmp ( primary, &primary_check, sizeof ( primary_check ) ) == 0){
511
+	if ( memcmp ( &scratch->primary.fixed, &primary_check,
512
+		      sizeof ( primary_check ) ) == 0 ) {
509 513
 		DBGC ( sandev, "SAN %#02x contains an ISO9660 filesystem; "
510 514
 		       "treating as CD-ROM\n", sandev->drive );
511 515
 		sandev->blksize_shift = blksize_shift;
@@ -513,7 +517,7 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
513 517
 	}
514 518
 
515 519
  err_rw:
516
-	free ( primary );
520
+	free ( scratch );
517 521
  err_alloc:
518 522
  invalid_blksize:
519 523
 	return rc;

Chargement…
Annuler
Enregistrer