]> Dogcows Code - chaz/tar/commitdiff
(decode_options): Check that volume label is not too long to overflow
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Oct 2000 05:21:06 +0000 (05:21 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Oct 2000 05:21:06 +0000 (05:21 +0000)
name in tar header block.

src/tar.c

index fcd23a8fc5f4b045bb1399a0f669d86f5d9c38f2..213b277921f1f17fdaf2188de16ec7040df3be32 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -726,7 +726,7 @@ decode_options (int argc, char **argv)
        /* Fall through.  */
 
       case NEWER_MTIME_OPTION:
-       if (newer_mtime_option != TYPE_MINIMUM (time_t))
+       if (newer_mtime_option != TYPE_MINIMUM (time_t))
          USAGE_ERROR ((0, 0, _("More than one threshold date")));
 
        newer_mtime_option = get_date (optarg, 0);
@@ -1107,6 +1107,24 @@ see the file named COPYING for details."),
     USAGE_ERROR ((0, 0,
                  _("Cannot combine --listed-incremental with --newer")));
 
+  if (volume_label_option)
+    {
+      size_t volume_label_max_len =
+       (sizeof current_header->header.name
+        - 1 /* for trailing '\0' */
+        - (multi_volume_option
+           ? (sizeof " Volume "
+              - 1 /* for null at end of " Volume " */
+              + INT_STRLEN_BOUND (int) /* for volume number */
+              - 1 /* for sign, as 0 <= volno */)
+           : 0));
+      if (volume_label_max_len < strlen (volume_label_option))
+       USAGE_ERROR ((0, 0,
+                     _("%s: Volume label is too long (limit is %lu bytes)"),
+                     quotearg_colon (volume_label_option),
+                     (unsigned long) volume_label_max_len));
+    }
+
   /* If ready to unlink hierarchies, so we are for simpler files.  */
   if (recursive_unlink_option)
     old_files_option = UNLINK_FIRST_OLD_FILES;
This page took 0.029173 seconds and 4 git commands to generate.