Compare commits
11 Commits
release-0.
...
release-0.
Author | SHA1 | Date | |
---|---|---|---|
d863451771 | |||
78308eea24 | |||
0ab2b8260c | |||
a30bd36a81 | |||
3814396b08 | |||
f88d8a76b0 | |||
6bc1395e15 | |||
6bf538ff40 | |||
c992687200 | |||
9cfa55345e | |||
d9a11a3b8d |
@ -261,6 +261,7 @@ EXTRA_DIST = \
|
||||
doc/susp_aaip_2_0.txt \
|
||||
doc/susp_aaip_isofs_names.txt \
|
||||
doc/zisofs_format.txt \
|
||||
doc/checksums.txt \
|
||||
libisofs/aaip-os-dummy.c \
|
||||
libisofs/aaip-os-linux.c \
|
||||
libisofs/aaip-os-freebsd.c
|
||||
|
14
configure.ac
14
configure.ac
@ -1,4 +1,4 @@
|
||||
AC_INIT([libisofs], [0.6.22], [http://libburnia-project.org])
|
||||
AC_INIT([libisofs], [0.6.24], [http://libburnia-project.org])
|
||||
AC_PREREQ([2.50])
|
||||
dnl AC_CONFIG_HEADER([config.h])
|
||||
|
||||
@ -37,14 +37,14 @@ dnl iso_lib_version(). It returns the major, minor and micro revision of the
|
||||
dnl library. This means LIBISOFS_*_VERSION kept its second job which does not
|
||||
dnl comply to the usual ways of configure.ac . I.e. now *officially* this is
|
||||
dnl the source code release version as announced to the public. It has no
|
||||
dnl conection to SONAME or libtool version numbering.
|
||||
dnl connection to SONAME or libtool version numbering.
|
||||
dnl It rather feeds the API function iso_lib_version().
|
||||
dnl
|
||||
dnl If LIBISOFS_*_VERSION changes, be sure to change AC_INIT above to match.
|
||||
dnl
|
||||
LIBISOFS_MAJOR_VERSION=0
|
||||
LIBISOFS_MINOR_VERSION=6
|
||||
LIBISOFS_MICRO_VERSION=22
|
||||
LIBISOFS_MICRO_VERSION=24
|
||||
LIBISOFS_VERSION=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION.$LIBISOFS_MICRO_VERSION
|
||||
|
||||
AC_SUBST(LIBISOFS_MAJOR_VERSION)
|
||||
@ -54,11 +54,11 @@ AC_SUBST(LIBISOFS_VERSION)
|
||||
|
||||
dnl Libtool versioning
|
||||
LT_RELEASE=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION
|
||||
# 2009.08.25 development jump has not yet happened
|
||||
# SONAME = 24 - 18 = 6 . Library name = libisofs.6.18.0
|
||||
LT_CURRENT=24
|
||||
# 2009.10.08 development jump has not yet happened
|
||||
# SONAME = 26 - 20 = 6 . Library name = libisofs.6.20.0
|
||||
LT_CURRENT=26
|
||||
LT_REVISION=0
|
||||
LT_AGE=18
|
||||
LT_AGE=20
|
||||
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
|
||||
|
||||
AC_SUBST(LT_RELEASE)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
by Thomas Schmitt - mailto:scdbackup@gmx.net
|
||||
Libburnia project - mailto:libburn-hackers@pykix.org
|
||||
16 Aug 2009
|
||||
26 Aug 2009
|
||||
|
||||
|
||||
MD5 is a 128 bit message digest with a very low probability to be the same for
|
||||
@ -67,8 +67,8 @@ The tree checksum tag is written after the ECMA-119 directory entries.
|
||||
The session checksum tag is written after all payload including the checksum
|
||||
array. (Then follows eventual padding.)
|
||||
|
||||
The tags are a single lines of printable text, padded by 0 bytes. They have
|
||||
the following format:
|
||||
The tags are single lines of printable text at the very beginning of a block
|
||||
of 2048 bytes. They have the following format:
|
||||
|
||||
Tag_id pos=# range_start=# range_size=# [session_start|next=#] md5=# self=#\n
|
||||
|
||||
@ -81,14 +81,13 @@ Tag_id distinguishes the following tag types
|
||||
A relocated superblock may appear at LBA 0 of an image which was produced for
|
||||
being stored in a disk file or on overwriteable media (e.g. DVD+R, BD-RE).
|
||||
Typically there is a first session recorded with a superblock at LBA 32 and
|
||||
the next session may follow shortly after its session tag. (There may be a gap
|
||||
of padding, often 150 blocks, and aligning to the next address that is
|
||||
divisible by 32.) Normally no session starts after the address given by
|
||||
parameter session_start=.
|
||||
the next session may follow shortly after its session tag. (Typically at the
|
||||
next block address which is divisible by 32.) Normally no session starts after
|
||||
the address given by parameter session_start=.
|
||||
|
||||
Session oriented media like CD-R[W], DVD+R, BD-R will have no relocated
|
||||
superblock but rather bear a table-of-content on media level (to be inquired
|
||||
by MMC commands(.
|
||||
by MMC commands).
|
||||
|
||||
|
||||
Example:
|
||||
@ -162,9 +161,14 @@ checksums as strings of 32 hex digits.
|
||||
The MD5 checksum of the tag itself up to and including the last hex digit of
|
||||
parameter "md5=".
|
||||
|
||||
The newline character at the end is mandatory. For now all bytes of the
|
||||
block after that newline shall be zero. There may arise future extensions.
|
||||
The newline character at the end is mandatory. After that newline there may
|
||||
follow more lines. Their meaning is not necessarily described in this document.
|
||||
|
||||
One such line type is the scdbackup checksum tag, an ancestor of libisofs tags
|
||||
which is suitable only for single session images which begin at LBA 0. It bears
|
||||
a checksum record which by its MD5 covers all bytes from LBA 0 up to the
|
||||
newline character preceding the scdbackup tag. See scdbackup/README appendix
|
||||
VERIFY for details.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@ -183,11 +187,11 @@ whether its MD5 matches the MD5 of the data blocks which were read before.
|
||||
|
||||
With tag type 2:
|
||||
|
||||
Keep the original MD5 context of the data blocks and clone
|
||||
one for obtaining the MD5 bytes.
|
||||
If the MD5s match, then compute the checksum block into the kept MD5 context
|
||||
and go on with reading and computing for the tree checksum tag. This will be
|
||||
found at block address next_tag, verified and parsed by:
|
||||
Keep the original MD5 context of the data blocks and clone one for obtaining
|
||||
the MD5 bytes.
|
||||
If the MD5s match, then compute the checksum block and all folowing ones into
|
||||
the kept MD5 context and go on with reading and computing for the tree checksum
|
||||
tag. This will be found at block address next_tag, verified and parsed by:
|
||||
iso_util_decode_md5_tag(block, &tag_type, &pos,
|
||||
&range_start, &range_size, &next_tag, md5, 3);
|
||||
|
||||
@ -200,14 +204,12 @@ With tag type 4:
|
||||
End the MD5 context and start a new context for the session which you will
|
||||
read next.
|
||||
|
||||
You may look for the first session by starting to read at LBA 32, or you may
|
||||
look for the last session by starting to read at the address given by parameter
|
||||
session_start=. The former is suitable for a check of the whole image, the
|
||||
latter is the shortest way to ensure that the tree of the last session is
|
||||
not corrupted.
|
||||
Then look for the actual session by starting to read at the address given by
|
||||
parameter session_start= which is returned by iso_util_decode_md5_tag() as
|
||||
next_tag. Go on by looking for tag type 2 and follow above prescription.
|
||||
|
||||
|
||||
Checking a Whole Session
|
||||
Checking the Data Part of the Session
|
||||
|
||||
In order to check the trustworthyness of a whole session, continue reading
|
||||
and checksumming after the tree was verified.
|
||||
@ -224,6 +226,20 @@ bytes in parameter md5 match the MD5 computed from the data blocks which were
|
||||
read before the tag block.
|
||||
|
||||
|
||||
Checking All Sessions
|
||||
|
||||
If the media is sequentially recordable, obtain a table of content and check
|
||||
the first track of each session as prescribed above in Checking Before Image
|
||||
Tree Loading and in Checking the Data Part of the Session.
|
||||
|
||||
With disk files or overwriteable media, look for a relocated superblock tag
|
||||
but do not hop to address next_tag (given by session_start=). Instead look at
|
||||
LBA 32 for the first session and check it as prescribed above.
|
||||
After reaching its end, round up the read address to the next multiple of 32
|
||||
and check whether it is smaller than session_start= from the super block.
|
||||
If so, expect another session to start there.
|
||||
|
||||
|
||||
Checking Single Files in a Loaded Image
|
||||
|
||||
An image may consist of many sessions wherein many data blocks may not belong
|
||||
|
@ -31,11 +31,13 @@
|
||||
#include "md5.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <langinfo.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* TODO #00011 : guard against bad path table usage with more than 65535 dirs
|
||||
@ -1132,6 +1134,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
|
||||
|
||||
target->md5_file_checksums = opts->md5_file_checksums;
|
||||
target->md5_session_checksum = opts->md5_session_checksum;
|
||||
strcpy(target->scdbackup_tag_parm, opts->scdbackup_tag_parm);
|
||||
target->scdbackup_tag_written = opts->scdbackup_tag_written;
|
||||
target->checksum_idx_counter = 0;
|
||||
target->checksum_ctx = NULL;
|
||||
target->checksum_counter = 0;
|
||||
@ -1627,6 +1631,7 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile)
|
||||
if (wopts == NULL) {
|
||||
return ISO_OUT_OF_MEM;
|
||||
}
|
||||
wopts->scdbackup_tag_written = NULL;
|
||||
|
||||
switch (profile) {
|
||||
case 0:
|
||||
@ -1866,6 +1871,44 @@ int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
|
||||
char *name, char *timestamp,
|
||||
char *tag_written)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
char eff_name[81], eff_time[19];
|
||||
int i;
|
||||
|
||||
for (i = 0; name[i] != 0 && i < 80; i++)
|
||||
if (isspace((int) ((unsigned char *) name)[i]))
|
||||
eff_name[i] = '_';
|
||||
else
|
||||
eff_name[i] = name[i];
|
||||
if (i == 0)
|
||||
eff_name[i++] = '_';
|
||||
eff_name[i] = 0;
|
||||
for (i = 0; timestamp[i] != 0 && i < 18; i++)
|
||||
if (isspace((int) ((unsigned char *) timestamp)[i]))
|
||||
eff_time[i] = '_';
|
||||
else
|
||||
eff_time[i] = timestamp[i];
|
||||
if (i == 0)
|
||||
eff_time[i++] = '_';
|
||||
eff_time[i] = 0;
|
||||
|
||||
sprintf(opts->scdbackup_tag_parm, "%s %s", eff_name, eff_time);
|
||||
|
||||
opts->scdbackup_tag_written = tag_written;
|
||||
if (tag_written != NULL)
|
||||
tag_written[0] = 0;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
int iso_write_opts_set_replace_mode(IsoWriteOpts *opts, int dir_mode,
|
||||
int file_mode, int uid, int gid)
|
||||
{
|
||||
|
@ -281,6 +281,22 @@ struct iso_write_opts {
|
||||
*/
|
||||
uint32_t data_start_lba;
|
||||
|
||||
/**
|
||||
* If not empty: A text holding parameters "name" and "timestamp" for
|
||||
* a scdbackup stream checksum tag. See scdbackup/README appendix VERIFY.
|
||||
* It makes sense only for single session images which start at LBA 0.
|
||||
* Such a tag may be part of a libisofs checksum tag block after the
|
||||
* session tag line. It then covers the whole session up to its own start
|
||||
* position.
|
||||
*/
|
||||
char scdbackup_tag_parm[100];
|
||||
|
||||
/* If not NULL: A pointer to an application provided array with
|
||||
at least 512 characters. The effectively written scdbackup tag
|
||||
will be copied to this memory location.
|
||||
*/
|
||||
char *scdbackup_tag_written;
|
||||
|
||||
};
|
||||
|
||||
typedef struct ecma119_image Ecma119Image;
|
||||
@ -464,6 +480,9 @@ struct ecma119_image
|
||||
is submitted with ecma119_image_new() ?
|
||||
*/
|
||||
|
||||
char scdbackup_tag_parm[100];
|
||||
char *scdbackup_tag_written;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
|
||||
/* Buffer for communication between burn_source and writer thread */
|
||||
|
@ -2127,15 +2127,34 @@ int read_pvm(_ImageFsData *data, uint32_t block)
|
||||
|
||||
/* fill volume attributes */
|
||||
/* TODO take care of input charset */
|
||||
data->volset_id = strcopy((char*)pvm->vol_set_id, 128);
|
||||
data->volume_id = strcopy((char*)pvm->volume_id, 32);
|
||||
data->publisher_id = strcopy((char*)pvm->publisher_id, 128);
|
||||
data->data_preparer_id = strcopy((char*)pvm->data_prep_id, 128);
|
||||
data->system_id = strcopy((char*)pvm->system_id, 32);
|
||||
data->application_id = strcopy((char*)pvm->application_id, 128);
|
||||
data->copyright_file_id = strcopy((char*)pvm->copyright_file_id, 37);
|
||||
data->abstract_file_id = strcopy((char*)pvm->abstract_file_id, 37);
|
||||
data->biblio_file_id = strcopy((char*)pvm->bibliographic_file_id, 37);
|
||||
data->volset_id = iso_util_strcopy_untail((char*)pvm->vol_set_id, 128);
|
||||
data->volume_id = iso_util_strcopy_untail((char*)pvm->volume_id, 32);
|
||||
data->publisher_id =
|
||||
iso_util_strcopy_untail((char*)pvm->publisher_id, 128);
|
||||
data->data_preparer_id =
|
||||
iso_util_strcopy_untail((char*)pvm->data_prep_id, 128);
|
||||
data->system_id = iso_util_strcopy_untail((char*)pvm->system_id, 32);
|
||||
data->application_id =
|
||||
iso_util_strcopy_untail((char*)pvm->application_id, 128);
|
||||
data->copyright_file_id =
|
||||
iso_util_strcopy_untail((char*) pvm->copyright_file_id, 37);
|
||||
data->abstract_file_id =
|
||||
iso_util_strcopy_untail((char*) pvm->abstract_file_id, 37);
|
||||
data->biblio_file_id =
|
||||
iso_util_strcopy_untail((char*) pvm->bibliographic_file_id, 37);
|
||||
if (data->copyright_file_id[0] == '_' && data->copyright_file_id[1] == 0 &&
|
||||
data->abstract_file_id[0] == '_' && data->abstract_file_id[1] == 0 &&
|
||||
data->biblio_file_id[0] == '_' && data->biblio_file_id[1] == 0) {
|
||||
/* This is bug output from libisofs <= 0.6.23 . The texts mean file
|
||||
names and should have been empty to indicate that there are no such
|
||||
files. It is obvious that not all three roles can be fulfilled by
|
||||
one file "_" so that one cannot spoil anything by assuming them
|
||||
empty now.
|
||||
*/
|
||||
data->copyright_file_id[0] = 0;
|
||||
data->abstract_file_id[0] = 0;
|
||||
data->biblio_file_id[0] = 0;
|
||||
}
|
||||
|
||||
data->nblocks = iso_read_bb(pvm->vol_space_size, 4, NULL);
|
||||
|
||||
|
@ -213,6 +213,8 @@ void iso_image_set_volset_id(IsoImage *image, const char *volset_id)
|
||||
|
||||
const char *iso_image_get_volset_id(const IsoImage *image)
|
||||
{
|
||||
if (image->volset_id == NULL)
|
||||
return "";
|
||||
return image->volset_id;
|
||||
}
|
||||
|
||||
@ -224,6 +226,8 @@ void iso_image_set_volume_id(IsoImage *image, const char *volume_id)
|
||||
|
||||
const char *iso_image_get_volume_id(const IsoImage *image)
|
||||
{
|
||||
if (image->volume_id == NULL)
|
||||
return "";
|
||||
return image->volume_id;
|
||||
}
|
||||
|
||||
@ -235,6 +239,8 @@ void iso_image_set_publisher_id(IsoImage *image, const char *publisher_id)
|
||||
|
||||
const char *iso_image_get_publisher_id(const IsoImage *image)
|
||||
{
|
||||
if (image->publisher_id == NULL)
|
||||
return "";
|
||||
return image->publisher_id;
|
||||
}
|
||||
|
||||
@ -247,6 +253,8 @@ void iso_image_set_data_preparer_id(IsoImage *image,
|
||||
|
||||
const char *iso_image_get_data_preparer_id(const IsoImage *image)
|
||||
{
|
||||
if (image->data_preparer_id == NULL)
|
||||
return "";
|
||||
return image->data_preparer_id;
|
||||
}
|
||||
|
||||
@ -258,6 +266,8 @@ void iso_image_set_system_id(IsoImage *image, const char *system_id)
|
||||
|
||||
const char *iso_image_get_system_id(const IsoImage *image)
|
||||
{
|
||||
if (image->system_id == NULL)
|
||||
return "";
|
||||
return image->system_id;
|
||||
}
|
||||
|
||||
@ -269,6 +279,8 @@ void iso_image_set_application_id(IsoImage *image, const char *application_id)
|
||||
|
||||
const char *iso_image_get_application_id(const IsoImage *image)
|
||||
{
|
||||
if (image->application_id == NULL)
|
||||
return "";
|
||||
return image->application_id;
|
||||
}
|
||||
|
||||
@ -281,6 +293,8 @@ void iso_image_set_copyright_file_id(IsoImage *image,
|
||||
|
||||
const char *iso_image_get_copyright_file_id(const IsoImage *image)
|
||||
{
|
||||
if (image->copyright_file_id == NULL)
|
||||
return "";
|
||||
return image->copyright_file_id;
|
||||
}
|
||||
|
||||
@ -293,6 +307,8 @@ void iso_image_set_abstract_file_id(IsoImage *image,
|
||||
|
||||
const char *iso_image_get_abstract_file_id(const IsoImage *image)
|
||||
{
|
||||
if (image->abstract_file_id == NULL)
|
||||
return "";
|
||||
return image->abstract_file_id;
|
||||
}
|
||||
|
||||
@ -304,6 +320,8 @@ void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id)
|
||||
|
||||
const char *iso_image_get_biblio_file_id(const IsoImage *image)
|
||||
{
|
||||
if (image->biblio_file_id == NULL)
|
||||
return "";
|
||||
return image->biblio_file_id;
|
||||
}
|
||||
|
||||
|
@ -1090,7 +1090,7 @@ int iso_lib_is_compatible(int major, int minor, int micro);
|
||||
*/
|
||||
#define iso_lib_header_version_major 0
|
||||
#define iso_lib_header_version_minor 6
|
||||
#define iso_lib_header_version_micro 22
|
||||
#define iso_lib_header_version_micro 24
|
||||
|
||||
/**
|
||||
* Usage discussion:
|
||||
@ -1446,11 +1446,38 @@ int iso_write_opts_set_sort_files(IsoWriteOpts *opts, int sort);
|
||||
*/
|
||||
int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files);
|
||||
|
||||
/**
|
||||
* Set the parameters "name" and "timestamp" for a scdbackup checksum tag.
|
||||
* It will be appended to the libisofs session tag if the image starts at
|
||||
* LBA 0 (see iso_write_opts_set_ms_block()). The scdbackup tag can be used
|
||||
* to verify the image by command scdbackup_verify <device> -auto_end.
|
||||
* See scdbackup/README appendix VERIFY for its inner details.
|
||||
*
|
||||
* @param name
|
||||
* A word of up to 80 characters. Typically <volno>_<totalno> telling
|
||||
* that this is volume <volno> of a total of <totalno> volumes.
|
||||
* @param timestamp
|
||||
* A string of 13 characters YYMMDD.hhmmss (e.g. A90831.190324).
|
||||
* A9 = 2009, B0 = 2010, B1 = 2011, ... C0 = 2020, ...
|
||||
* @param tag_written
|
||||
* Either NULL or the address of an array with at least 512 characters.
|
||||
* In the latter case the eventually produced scdbackup tag will be
|
||||
* copied to this array when the image gets written. This call sets
|
||||
* scdbackup_tag_written[0] = 0 to mark its preliminary invalidity.
|
||||
* @return
|
||||
* 1 indicates success, <0 is error
|
||||
*
|
||||
* @since 0.6.24
|
||||
*/
|
||||
int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts,
|
||||
char *name, char *timestamp,
|
||||
char *tag_written);
|
||||
|
||||
/**
|
||||
* Whether to set default values for files and directory permissions, gid and
|
||||
* uid. All these take one of three values: 0, 1 or 2.
|
||||
*
|
||||
* If 0, the corresponding attribute will be kept as setted in the IsoNode.
|
||||
* If 0, the corresponding attribute will be kept as set in the IsoNode.
|
||||
* Unless you have changed it, it corresponds to the value on disc, so it
|
||||
* is suitable for backup purposes. If set to 1, the corresponding attrib.
|
||||
* will be changed by a default suitable value. Finally, if you set it to
|
||||
@ -5522,6 +5549,13 @@ int iso_md5_match(char first_md5[16], char second_md5[16]);
|
||||
*/
|
||||
#define ISO_MD5_STREAM_CHANGE 0xE430FE9A
|
||||
|
||||
/**
|
||||
* Session does not start at LBA 0. scdbackup checksum tag not written.
|
||||
* (WARNING, HIGH, -359)
|
||||
* @since 0.6.24
|
||||
*/
|
||||
#define ISO_SCDBACKUP_TAG_NOT_0 0xD030FE99
|
||||
|
||||
|
||||
/* ! PLACE NEW ERROR CODES HERE ! */
|
||||
|
||||
|
@ -698,6 +698,69 @@ int checksum_writer_create(Ecma119Image *target)
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int iso_md5_write_scdbackup_tag(Ecma119Image *t, char *tag_block, int flag)
|
||||
{
|
||||
|
||||
#ifdef Libisofs_with_checksumS
|
||||
|
||||
void *ctx = NULL;
|
||||
off_t pos = 0, line_start;
|
||||
int record_len, block_len, res, i;
|
||||
char postext[40], md5[16], record[160];
|
||||
|
||||
line_start = strlen(tag_block);
|
||||
iso_md5_compute(t->checksum_ctx, tag_block, line_start);
|
||||
res = iso_md5_clone(t->checksum_ctx, &ctx);
|
||||
if (res < 0)
|
||||
goto ex;
|
||||
res = iso_md5_end(&ctx, md5);
|
||||
|
||||
pos = (off_t) t->checksum_tag_pos * (off_t) 2048 + line_start;
|
||||
if(pos >= 1000000000)
|
||||
sprintf(postext, "%u%9.9u", (unsigned int) (pos / 1000000000),
|
||||
(unsigned int) (pos % 1000000000));
|
||||
else
|
||||
sprintf(postext, "%u", (unsigned int) pos);
|
||||
sprintf(record, "%s %s ", t->scdbackup_tag_parm, postext);
|
||||
record_len = strlen(record);
|
||||
for (i = 0; i < 16; i++)
|
||||
sprintf(record + record_len + 2 * i,
|
||||
"%2.2x", ((unsigned char *) md5)[i]);
|
||||
record_len += 32;
|
||||
|
||||
res = iso_md5_start(&ctx);
|
||||
if (res < 0)
|
||||
goto ex;
|
||||
iso_md5_compute(ctx, record, record_len);
|
||||
iso_md5_end(&ctx, md5);
|
||||
|
||||
sprintf(tag_block + line_start, "scdbackup_checksum_tag_v0.1 %s %d %s ",
|
||||
postext, record_len, record);
|
||||
block_len = strlen(tag_block);
|
||||
for (i = 0; i < 16; i++)
|
||||
sprintf(tag_block + block_len + 2 * i,
|
||||
"%2.2x", ((unsigned char *) md5)[i]);
|
||||
block_len+= 32;
|
||||
tag_block[block_len++]= '\n';
|
||||
|
||||
if (t->scdbackup_tag_written != NULL)
|
||||
strncpy(t->scdbackup_tag_written, tag_block + line_start,
|
||||
block_len - line_start);
|
||||
res = ISO_SUCCESS;
|
||||
ex:;
|
||||
if (ctx != NULL)
|
||||
iso_md5_end(&ctx, md5);
|
||||
return res;
|
||||
|
||||
#else
|
||||
|
||||
return ISO_SUCCESS;
|
||||
|
||||
#endif /* Libisofs_with_checksumS */
|
||||
}
|
||||
|
||||
|
||||
/* Write stream detectable checksum tag to extra block.
|
||||
* @flag bit0-7= tag type
|
||||
* 1= session tag (End checksumming.)
|
||||
@ -719,11 +782,16 @@ int iso_md5_write_tag(Ecma119Image *t, int flag)
|
||||
start = t->checksum_range_start;
|
||||
memset(tag_block, 0, 2048);
|
||||
mode = flag & 255;
|
||||
if (mode < 1 || mode > 4)
|
||||
return ISO_WRONG_ARG_VALUE;
|
||||
res = iso_md5_clone(t->checksum_ctx, &ctx);
|
||||
if (res < 0)
|
||||
return res;
|
||||
res = iso_md5_end(&ctx, md5);
|
||||
if (mode == 1) {
|
||||
res = iso_md5_end(&(t->checksum_ctx), md5);
|
||||
size = t->checksum_range_size;
|
||||
pos = t->checksum_tag_pos;
|
||||
} else if (mode >= 2 && mode <= 4) {
|
||||
} else {
|
||||
if (mode == 2) {
|
||||
pos = t->checksum_sb_tag_pos;
|
||||
} else if (mode == 3) {
|
||||
@ -733,17 +801,12 @@ int iso_md5_write_tag(Ecma119Image *t, int flag)
|
||||
start = pos - (pos % 32);
|
||||
}
|
||||
size = pos - start;
|
||||
res = iso_md5_clone(t->checksum_ctx, &ctx);
|
||||
if (res < 0)
|
||||
return res;
|
||||
res = iso_md5_end(&ctx, md5);
|
||||
} else {
|
||||
return ISO_WRONG_ARG_VALUE;
|
||||
}
|
||||
if (res > 0) {
|
||||
if (res < 0)
|
||||
goto ex;
|
||||
|
||||
iso_util_tag_magic(mode, &tag_id, &tag_id_len, 0);
|
||||
sprintf(tag_block,
|
||||
"%s pos=%u range_start=%u range_size=%u",
|
||||
sprintf(tag_block, "%s pos=%u range_start=%u range_size=%u",
|
||||
tag_id, pos, start, size);
|
||||
|
||||
l = strlen(tag_block);
|
||||
@ -772,7 +835,17 @@ int iso_md5_write_tag(Ecma119Image *t, int flag)
|
||||
((unsigned char *) md5)[i]);
|
||||
}
|
||||
tag_block[l + 32] = '\n';
|
||||
|
||||
if (mode == 1 && t->scdbackup_tag_parm[0]) {
|
||||
if (t->ms_block > 0) {
|
||||
iso_msg_submit(t->image->id, ISO_SCDBACKUP_TAG_NOT_0, 0, NULL);
|
||||
} else {
|
||||
res = iso_md5_write_scdbackup_tag(t, tag_block, 0);
|
||||
if (res < 0)
|
||||
goto ex;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == 4) {
|
||||
if (t->opts_overwrite != NULL)
|
||||
memcpy(t->opts_overwrite + pos * 2048, tag_block, 2048);
|
||||
@ -783,6 +856,7 @@ int iso_md5_write_tag(Ecma119Image *t, int flag)
|
||||
goto ex;
|
||||
}
|
||||
}
|
||||
|
||||
res = ISO_SUCCESS;
|
||||
ex:;
|
||||
if (ctx != NULL)
|
||||
|
@ -274,6 +274,8 @@ const char *iso_error_to_msg(int errcode)
|
||||
return "Checksum tag with unexpected address range encountered";
|
||||
case ISO_MD5_STREAM_CHANGE:
|
||||
return "Detected file content changes while it was written into the image";
|
||||
case ISO_SCDBACKUP_TAG_NOT_0:
|
||||
return "Session does not start at LBA 0. scdbackup checksum tag not written.";
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ int read_rr_NM(struct susp_sys_user_entry *nm, char **name, int *cont)
|
||||
*name = realloc(*name, strlen(*name) + nm->len_sue[0] - 5 + 1);
|
||||
strncat(*name, (char*)nm->data.NM.name, nm->len_sue[0] - 5);
|
||||
} else {
|
||||
*name = strcopy((char*)nm->data.NM.name, nm->len_sue[0] - 5);
|
||||
*name = iso_util_strcopy((char*)nm->data.NM.name, nm->len_sue[0] - 5);
|
||||
}
|
||||
if (*name == NULL) {
|
||||
return ISO_OUT_OF_MEM;
|
||||
@ -380,7 +380,7 @@ int read_rr_SL(struct susp_sys_user_entry *sl, char **dest, int *cont)
|
||||
/* we don't have to add the '/' */
|
||||
strncat(*dest, comp, len);
|
||||
} else {
|
||||
*dest = strcopy(comp, len);
|
||||
*dest = iso_util_strcopy(comp, len);
|
||||
}
|
||||
if (*dest == NULL) {
|
||||
return ISO_OUT_OF_MEM;
|
||||
|
@ -1381,21 +1381,33 @@ int iso_eaccess(const char *path)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
char *strcopy(const char *buf, size_t len)
|
||||
char *iso_util_strcopy(const char *buf, size_t len)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = malloc((len + 1) * sizeof(char));
|
||||
str = calloc(len + 1, 1);
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(str, buf, len);
|
||||
str[len] = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
char *iso_util_strcopy_untail(const char *buf, size_t len)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = iso_util_strcopy(buf, len);
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
/* remove trailing spaces */
|
||||
for (len = len-1; str[len] == ' ' && len > 0; --len)
|
||||
str[len] = '\0';
|
||||
|
||||
for (len = len-1; len >= 0; --len) {
|
||||
if (str[len] != ' ')
|
||||
break;
|
||||
str[len] = 0;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -246,11 +246,32 @@ time_t iso_datetime_read_17(const uint8_t *buf);
|
||||
*/
|
||||
int iso_eaccess(const char *path);
|
||||
|
||||
#ifdef NIX
|
||||
/* <<< Buggy and not used any more */
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
* Note:
|
||||
* Trailing blanks will be removed. But the first one of an all blank string
|
||||
* persists. It is unclear whether this is a bug or a feature.
|
||||
*/
|
||||
char *strcopy(const char *buf, size_t len);
|
||||
|
||||
#endif /* NIX */
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
*/
|
||||
char *strcopy(const char *buf, size_t len);
|
||||
char *iso_util_strcopy(const char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
* Any trailing blanks will be removed.
|
||||
*/
|
||||
char *iso_util_strcopy_untail(const char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Copy up to \p max characters from \p src to \p dest. If \p src has less than
|
||||
|
Reference in New Issue
Block a user