Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Test failures in sharutils-4.13.3

3 views
Skip to first unread message

Peter Fales

unread,
Mar 4, 2013, 5:14:34 PM3/4/13
to bug-gn...@gnu.org
I'm getting corrupt output from sharutils when the -L option is used.

If gotten as far determing that SPLIT_SIZE_LIMIT is marked as
unused when it reaches line 970 in shar.c, so archive_type_position
is not set on line 980.

970 if (HAVE_OPT(SPLIT_SIZE_LIMIT))
971 {
972 int len = snprintf (explain_text_fmt, sizeof (explain_text_fmt),
973 explain_fmt_fmt, explain_1_len, explain_2_len);
974 if ((unsigned)len >= sizeof (explain_text_fmt))
975 strcpy (explain_text_fmt, "#%-256s\n#%-256s\n");
976
977 /* May be split, provide for white space for an explanation. */
978
979 fputs ("#\n", output);
980 archive_type_position = ftell (output);
981 fprintf (output, explain_text_fmt, "", "");
982 }

When it later hits line 1385, it seeks to position 0 and clobbers the
first part of the file.


1381 if (part_number == 1)
1382 {
1383 /* Rewrite the info lines on the first header. */
1384
1385 fseek (output, archive_type_position, SEEK_SET);
1386 fprintf (output, explain_text_fmt, explain_1, explain_2);
1387 }

I don't understand the option parsing code well enough to understand
why the test on line 970 is failing.


--
Peter Fales
Alcatel-Lucent
Member of Technical Staff
1960 Lucent Lane
Room: 9H-505
Naperville, IL 60566-7033
Email: Peter...@alcatel-lucent.com
Phone: 630 979 8031

Bruce Korb

unread,
Mar 4, 2013, 9:50:25 PM3/4/13
to Peter Fales, bug-gn...@gnu.org
On 03/04/13 14:14, Peter Fales wrote:
> I'm getting corrupt output from sharutils when the -L option is used.

Uh, oh.

> If gotten as far determing that SPLIT_SIZE_LIMIT is marked as
> unused when it reaches line 970 in shar.c, so archive_type_position
> is not set on line 980.

The options "-l" and "-L" form an option "equivalence class".
The status of the option should be tested with HAVE_OPT(WHOLE_SIZE_LIMIT)
not HAVE_OPT(SPLIT_SIZE_LIMIT).

I'm in the middle of patches for I18N, so here is a hand patch for it:

$ diff -u shar.c~ shar.c
--- shar.c~ 2013-01-04 22:16:01.000000000 -0800
+++ shar.c 2013-03-04 18:49:11.894292390 -0800
@@ -967,7 +967,7 @@
fputs ("# The unsharer will be INTERACTIVELY queried.\n",
output);

- if (HAVE_OPT(SPLIT_SIZE_LIMIT))
+ if (HAVE_OPT(WHOLE_SIZE_LIMIT))
{
int len = snprintf (explain_text_fmt, sizeof (explain_text_fmt),
explain_fmt_fmt, explain_1_len, explain_2_len);
@@ -1563,8 +1563,9 @@
*size_left_p = OPT_VALUE_WHOLE_SIZE_LIMIT - current_size;
DEBUG_PRINT (_("In shar: remaining size %s\n"), *size_left_p);

- if (!HAVE_OPT(SPLIT_SIZE_LIMIT) && current_size > first_file_position
- && (encoded_size > *size_left_p))
+ if ( (WHICH_OPT_WHOLE_SIZE_LIMIT != VALUE_OPT_SPLIT_SIZE_LIMIT)
+ && (current_size > first_file_position)
+ && (encoded_size > *size_left_p))
{
change_files (*rnameq_p, size_left_p);
current_size = ftell (output);
@@ -2202,7 +2203,7 @@

/* Delete the sequence file, if any. */

- if (HAVE_OPT(SPLIT_SIZE_LIMIT) && part_number > 1)
+ if (HAVE_OPT(WHOLE_SIZE_LIMIT) && part_number > 1)
{
fprintf (output, echo_string_z, SM_you_are_done);
if (HAVE_OPT(QUIET))

Peter Fales

unread,
Mar 4, 2013, 10:53:34 PM3/4/13
to Bruce Korb, bug-gn...@gnu.org
Thanks for the patch. That made a difference, but still doesn't seem
quite right. When -L is used the first archive looks like this:

1 #!/bin/sh
2 # This is shar-3-test, a shell archive (produced by GNU sharutils 4.13.3).
3 # To extract the files from this archive, save it to some FILE, remove
4 # everything before the `#!/bin/sh' line above, then type `sh FILE'.
5 #
6 lock_dir=_sh20644
7 # Made on 2013-03-04 21:46 CST by <exp...@ilxexp1.ih.lucent.com>.
8 # Source directory was `/opt/exp/expmake/build/gnucoresrc/build/sharutils'.
9 #
10 # Existing files will *not* be overwritten, unless `-c' is specified.
11 #
12 # This is part 1 of a multipart archive.
13 # Do not concatenate these parts, unpack them in orderwith `/bin/sh'.
14 echo 2 > ${lock_dir}/seq
15 exit 0
16 mode name
17 # ------ ---------- ------------------------------------------
18 # 788742 -rwxrwxr-x configure
19 #

The "echo 2" line moved from a byte offset of 0 at the very beginning
of the file to it's current location at line 14. However, nothing has
created that directory, so the script dies on line 14.

Bruce Korb

unread,
Mar 7, 2013, 3:49:18 PM3/7/13
to Peter Fales, bug-gn...@gnu.org
On 03/04/13 19:53, Peter Fales wrote:
> Thanks for the patch. That made a difference, but still doesn't seem
> quite right. When -L is used the first archive looks like this:

There were three bugs, one inconsequential.
The first (fixed before) masked the second. *sigh*.

> The "echo 2" line moved from a byte offset of 0 at the very beginning
> of the file to it's current location at line 14. However, nothing has
> created that directory, so the script dies on line 14.

It belongs at the very end. The second script must verify that it is
its turn to run.

--- sharutils-4.13.3-ori/src/shar.c 2013-01-04 22:16:01.000000000 -0800
+++ sharutils-4.13.3/src/shar.c 2013-03-07 12:41:32.436600712 -0800
@@ -965,11 +965,11 @@

if (HAVE_OPT(QUERY_USER))
fputs ("# The unsharer will be INTERACTIVELY queried.\n",
output);

- if (HAVE_OPT(SPLIT_SIZE_LIMIT))
+ if (HAVE_OPT(WHOLE_SIZE_LIMIT))
{
int len = snprintf (explain_text_fmt, sizeof (explain_text_fmt),
explain_fmt_fmt, explain_1_len, explain_2_len);
if ((unsigned)len >= sizeof (explain_text_fmt))
strcpy (explain_text_fmt, "#%-256s\n#%-256s\n");
@@ -1374,18 +1374,19 @@
snprintf (scribble, scribble_size, SM_contin_in_part,
restore, (long)part_number + 1);
fprintf (output, echo_string_z, scribble);
}

- fwrite (split_file_z, sizeof (split_file_z), 1, output);
+ fwrite (split_file_z, sizeof (split_file_z) - 1, 1, output);

if (part_number == 1)
{
/* Rewrite the info lines on the first header. */

fseek (output, archive_type_position, SEEK_SET);
fprintf (output, explain_text_fmt, explain_1, explain_2);
+ fseek (output, 0, SEEK_END);
}
close_output (part_number + 1);

/* Next! */

@@ -1561,12 +1562,13 @@
: struct_stat.st_size);

*size_left_p = OPT_VALUE_WHOLE_SIZE_LIMIT - current_size;
DEBUG_PRINT (_("In shar: remaining size %s\n"), *size_left_p);

- if (!HAVE_OPT(SPLIT_SIZE_LIMIT) && current_size > first_file_position
- && (encoded_size > *size_left_p))
+ if ( (WHICH_OPT_WHOLE_SIZE_LIMIT != VALUE_OPT_SPLIT_SIZE_LIMIT)
+ && (current_size > first_file_position)
+ && (encoded_size > *size_left_p))
{
change_files (*rnameq_p, size_left_p);
current_size = ftell (output);
*size_left_p = OPT_VALUE_WHOLE_SIZE_LIMIT - current_size;
}
@@ -2200,11 +2202,11 @@
}
}

/* Delete the sequence file, if any. */

- if (HAVE_OPT(SPLIT_SIZE_LIMIT) && part_number > 1)
+ if (HAVE_OPT(WHOLE_SIZE_LIMIT) && part_number > 1)
{
fprintf (output, echo_string_z, SM_you_are_done);
if (HAVE_OPT(QUIET))
fprintf (stderr, _("Created %d files\n"), part_number);
}


0 new messages