Bug fix: Volume descriptors of Joliet and ISO 9660:1999 beared non-zero

Effective Date, involuntarily restricting the early end of their lifetime.
Thanks to Vladimir Serbinenko.
This commit is contained in:
Thomas Schmitt 2012-05-22 16:46:17 +02:00
parent 3c7c534ded
commit 6982971796
5 changed files with 74 additions and 47 deletions

View File

@ -451,6 +451,51 @@ char *get_relaxed_vol_id(Ecma119Image *t, const char *name)
return strdup(name); return strdup(name);
} }
void ecma119_set_voldescr_times(IsoImageWriter *writer,
struct ecma119_pri_vol_desc *vol)
{
Ecma119Image *t = writer->target;
int i;
if (t->vol_uuid[0]) {
for(i = 0; i < 16; i++)
if(t->vol_uuid[i] < '0' || t->vol_uuid[i] > '9')
break;
else
vol->vol_creation_time[i] = t->vol_uuid[i];
for(; i < 16; i++)
vol->vol_creation_time[i] = '1';
vol->vol_creation_time[16] = 0;
} else if (t->vol_creation_time > 0)
iso_datetime_17(vol->vol_creation_time, t->vol_creation_time,
t->always_gmt);
else
iso_datetime_17(vol->vol_creation_time, t->now, t->always_gmt);
if (t->vol_uuid[0]) {
for(i = 0; i < 16; i++)
if(t->vol_uuid[i] < '0' || t->vol_uuid[i] > '9')
break;
else
vol->vol_modification_time[i] = t->vol_uuid[i];
for(; i < 16; i++)
vol->vol_modification_time[i] = '1';
vol->vol_modification_time[16] = 0;
} else if (t->vol_modification_time > 0)
iso_datetime_17(vol->vol_modification_time, t->vol_modification_time,
t->always_gmt);
else
iso_datetime_17(vol->vol_modification_time, t->now, t->always_gmt);
if (t->vol_expiration_time > 0)
iso_datetime_17(vol->vol_expiration_time, t->vol_expiration_time,
t->always_gmt);
if (t->vol_effective_time > 0)
iso_datetime_17(vol->vol_effective_time, t->vol_effective_time,
t->always_gmt);
}
/** /**
* Write the Primary Volume Descriptor (ECMA-119, 8.4) * Write the Primary Volume Descriptor (ECMA-119, 8.4)
*/ */
@ -460,7 +505,6 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
IsoImage *image; IsoImage *image;
Ecma119Image *t; Ecma119Image *t;
struct ecma119_pri_vol_desc vol; struct ecma119_pri_vol_desc vol;
int i;
char *vol_id, *pub_id, *data_id, *volset_id; char *vol_id, *pub_id, *data_id, *volset_id;
char *system_id, *application_id, *copyright_file_id; char *system_id, *application_id, *copyright_file_id;
char *abstract_file_id, *biblio_file_id; char *abstract_file_id, *biblio_file_id;
@ -526,44 +570,7 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
strncpy_pad((char*)vol.abstract_file_id, abstract_file_id, 37); strncpy_pad((char*)vol.abstract_file_id, abstract_file_id, 37);
strncpy_pad((char*)vol.bibliographic_file_id, biblio_file_id, 37); strncpy_pad((char*)vol.bibliographic_file_id, biblio_file_id, 37);
if (t->vol_uuid[0]) { ecma119_set_voldescr_times(writer, &vol);
for(i = 0; i < 16; i++)
if(t->vol_uuid[i] < '0' || t->vol_uuid[i] > '9')
break;
else
vol.vol_creation_time[i] = t->vol_uuid[i];
for(; i < 16; i++)
vol.vol_creation_time[i] = '1';
vol.vol_creation_time[16] = 0;
} else if (t->vol_creation_time > 0)
iso_datetime_17(vol.vol_creation_time, t->vol_creation_time,
t->always_gmt);
else
iso_datetime_17(vol.vol_creation_time, t->now, t->always_gmt);
if (t->vol_uuid[0]) {
for(i = 0; i < 16; i++)
if(t->vol_uuid[i] < '0' || t->vol_uuid[i] > '9')
break;
else
vol.vol_modification_time[i] = t->vol_uuid[i];
for(; i < 16; i++)
vol.vol_modification_time[i] = '1';
vol.vol_modification_time[16] = 0;
} else if (t->vol_modification_time > 0)
iso_datetime_17(vol.vol_modification_time, t->vol_modification_time,
t->always_gmt);
else
iso_datetime_17(vol.vol_modification_time, t->now, t->always_gmt);
if (t->vol_expiration_time > 0)
iso_datetime_17(vol.vol_expiration_time, t->vol_expiration_time,
t->always_gmt);
if (t->vol_effective_time > 0)
iso_datetime_17(vol.vol_effective_time, t->vol_effective_time,
t->always_gmt);
vol.file_structure_version[0] = 1; vol.file_structure_version[0] = 1;
free(vol_id); free(vol_id);

View File

@ -881,5 +881,7 @@ struct ecma119_vol_desc_terminator
uint8_t reserved BP(8, 2048); uint8_t reserved BP(8, 2048);
}; };
void ecma119_set_voldescr_times(IsoImageWriter *writer,
struct ecma119_pri_vol_desc *vol);
#endif /*LIBISO_ECMA119_H_*/ #endif /*LIBISO_ECMA119_H_*/

View File

@ -19,6 +19,7 @@
#include "filesrc.h" #include "filesrc.h"
#include "eltorito.h" #include "eltorito.h"
#include "util.h" #include "util.h"
#include "ecma119.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -801,9 +802,7 @@ int iso1999_writer_write_vol_desc(IsoImageWriter *writer)
strncpy_pad((char*)vol.abstract_file_id, abstract_file_id, 37); strncpy_pad((char*)vol.abstract_file_id, abstract_file_id, 37);
strncpy_pad((char*)vol.bibliographic_file_id, biblio_file_id, 37); strncpy_pad((char*)vol.bibliographic_file_id, biblio_file_id, 37);
iso_datetime_17(vol.vol_creation_time, t->now, t->always_gmt); ecma119_set_voldescr_times(writer, (struct ecma119_pri_vol_desc *) &vol);
iso_datetime_17(vol.vol_modification_time, t->now, t->always_gmt);
iso_datetime_17(vol.vol_effective_time, t->now, t->always_gmt);
vol.file_structure_version[0] = 2; vol.file_structure_version[0] = 2;
free(vol_id); free(vol_id);

View File

@ -21,6 +21,7 @@
#include "eltorito.h" #include "eltorito.h"
#include "libisofs.h" #include "libisofs.h"
#include "util.h" #include "util.h"
#include "ecma119.h"
#include <stdlib.h> #include <stdlib.h>
@ -911,9 +912,7 @@ int joliet_writer_write_vol_desc(IsoImageWriter *writer)
ucsncpy_pad((uint16_t*)vol.abstract_file_id, abstract_file_id, 37); ucsncpy_pad((uint16_t*)vol.abstract_file_id, abstract_file_id, 37);
ucsncpy_pad((uint16_t*)vol.bibliographic_file_id, biblio_file_id, 37); ucsncpy_pad((uint16_t*)vol.bibliographic_file_id, biblio_file_id, 37);
iso_datetime_17(vol.vol_creation_time, t->now, t->always_gmt); ecma119_set_voldescr_times(writer, (struct ecma119_pri_vol_desc *) &vol);
iso_datetime_17(vol.vol_modification_time, t->now, t->always_gmt);
iso_datetime_17(vol.vol_effective_time, t->now, t->always_gmt);
vol.file_structure_version[0] = 1; vol.file_structure_version[0] = 1;
free(vol_id); free(vol_id);

View File

@ -2111,7 +2111,10 @@ int iso_write_opts_set_disc_label(IsoWriteOpts *opts, char *label);
/** /**
* Explicitely set the four timestamps of the emerging Primary Volume * Explicitely set the four timestamps of the emerging Primary Volume
* Descriptor. Default with all parameters is 0. * Descriptor and in the volume descriptors of Joliet and ISO 9660:1999,
* if those are to be generated.
* Default with all parameters is 0.
*
* ECMA-119 defines them as: * ECMA-119 defines them as:
* @param opts * @param opts
* The option set to be manipulated. * The option set to be manipulated.
@ -3190,7 +3193,7 @@ int el_torito_get_bootable(ElToritoBootImage *bootimg);
* the CD-ROM". * the CD-ROM".
* Further boot images put 28 bytes into their Section Header. * Further boot images put 28 bytes into their Section Header.
* El Torito 1.0 states that "If the BIOS understands the ID string, it * El Torito 1.0 states that "If the BIOS understands the ID string, it
* may choose to boot the * system using one of these entries in place * may choose to boot the system using one of these entries in place
* of the INITIAL/DEFAULT entry." (The INITIAL/DEFAULT entry points to the * of the INITIAL/DEFAULT entry." (The INITIAL/DEFAULT entry points to the
* first boot image.) * first boot image.)
* @return * @return
@ -3300,6 +3303,23 @@ int el_torito_seems_boot_info_table(ElToritoBootImage *bootimg, int flag);
* For that you need isolinux.bin from SYSLINUX 3.72 or later. * For that you need isolinux.bin from SYSLINUX 3.72 or later.
* IMPORTANT: The application has to take care that the image * IMPORTANT: The application has to take care that the image
* on media gets padded up to the next full MB. * on media gets padded up to the next full MB.
>>> unless a GPT gets created
* >>> *** Under construction. *** Do not use yet:
* >>> bit2-7= Mentioning in isohybrid GPT
* >>> 0= do not mention in GPT
* >>> 1= mention as EFI partition
* >>> @since 1.2.4
* >>> 2= Mention as HFS+ partition
* >>> @since 1.2.4
* >>> Primary GPT and backup GPT get written if at least one
* >>> ElToritoBootImage shall be mentioned
* >>> bit8= Mention in isohybrid Apple partition map
* >>> APM get written if at least one ElToritoBootImage shall be
* >>> mentioned. The ISOLINUX MBR must look suitable or else an error
* >>> event will happen at image generation time.
* >>> @since 1.2.4
* @param flag * @param flag
* Reserved for future usage, set to 0. * Reserved for future usage, set to 0.
* @return * @return