Skip to content

Commit

Permalink
3378 cdrw is unable to write some ISO images
Browse files Browse the repository at this point in the history
Reviewed by: Gary Mills <gary_mills@fastmail.fm>
Reviewed by: Milan Jurik <milan.jurik@xylab.cz>
Approved by: Richard Lowe <richlowe@richlowe.net>
  • Loading branch information
mtelka authored and richlowe committed Dec 4, 2012
1 parent e690fb2 commit eab441e
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions usr/src/cmd/cdrw/bstream.c
Expand Up @@ -22,8 +22,9 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2012 Marcel Telka <marcel@telka.sk>
*/

#include <fcntl.h>
#include <string.h>
Expand Down Expand Up @@ -297,42 +298,44 @@ open_iso_read_stream(char *fname)
return (NULL);

if (debug)
(void) printf("Checking the ISO 9660 file header\n");
(void) printf("Checking the ISO file header\n");

/* Check to see if we have a valid sized ISO image */
h->bstr_size(h, &iso_size);
if (iso_size < ISO9660_HEADER_SIZE) {
if (debug)
(void) printf("ISO 9660 header size not sane.\n");
(void) printf("ISO header size not sane.\n");
h->bstr_close(h);
str_errno = STR_ERR_ISO_BAD_HEADER;
return (NULL);
}

if (debug)
(void) printf("ISO 9660 header size is sane.\n");
(void) printf("ISO header size is sane.\n");

/* Skip over the boot block sector of the ISO. */
(void) lseek(h->bstr_fd, ISO9660_BOOT_BLOCK_SIZE, SEEK_SET);

/*
* Try to read in the ISO Descriptor and validate this
* is in fact an ISO 9660 image.
* is in fact an ISO image.
*/
if (read(h->bstr_fd, iso_desc, ISO9660_PRIMARY_DESC_SIZE) ==
ISO9660_PRIMARY_DESC_SIZE) {
/*
* Bytes one through five of a valid ISO 9660 cd image
* should contain the string CD001. High Sierra format,
* the ISO 9660 predecessor, fills this field with the
* string CDROM. If neither is the case then we should
* close the stream, set str_errno, and return NULL.
* Bytes one through five of a valid image should contain:
* - BEA01 (ISO 13490 image)
* - CD001 (ISO 9660 or ISO 13490 image)
* - CDROM (High Sierra format, the ISO 9660 predecessor)
* If neither is the case then we should close the stream,
* set str_errno, and return NULL.
*/
if (strncmp(iso_desc + ISO9660_STD_IDENT_OFFSET, "CD001",
if (strncmp(iso_desc + ISO9660_STD_IDENT_OFFSET, "BEA01",
5) != 0 && strncmp(iso_desc + ISO9660_STD_IDENT_OFFSET,
"CDROM", 5) != 0) {
"CD001", 5) != 0 && strncmp(iso_desc +
ISO9660_STD_IDENT_OFFSET, "CDROM", 5) != 0) {
if (debug)
(void) printf("Invalid ISO 9660 identifier.\n");
(void) printf("Invalid ISO identifier.\n");
h->bstr_close(h);
str_errno = STR_ERR_ISO_BAD_HEADER;
return (NULL);
Expand All @@ -348,7 +351,7 @@ open_iso_read_stream(char *fname)
* and return the handle.
*/
if (debug)
(void) printf("ISO 9660 header is sane.\n");
(void) printf("ISO header is sane.\n");
h->bstr_rewind(h);
return (h);
}
Expand Down Expand Up @@ -488,7 +491,7 @@ open_wav_read_stream(char *fname)
goto wav_open_failed;
}
if ((strncmp(wav->riff, "RIFF", 4) != 0) ||
(strncmp(wav->wave, "WAVE", 4) != 0)) {
(strncmp(wav->wave, "WAVE", 4) != 0)) {
str_errno = STR_ERR_WAV_BAD_HEADER;
goto wav_open_failed;
}
Expand Down

0 comments on commit eab441e

Please sign in to comment.