[ostree] core: Handle zero-sized archives, improve fsck error message



commit 3321fa08d74dc4f6fcec81a0a007a7c728e792fe
Author: Colin Walters <walters verbum org>
Date:   Fri May 4 13:40:25 2012 -0400

    core: Handle zero-sized archives, improve fsck error message

 src/libostree/ostree-core.c  |    6 ++++++
 src/ostree/ot-builtin-fsck.c |   10 ++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 1f352a7..77c31fe 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -417,6 +417,12 @@ ostree_content_stream_parse (GInputStream           *input,
                    (guint)archive_header_size, input_length);
       goto out;
     }
+  if (archive_header_size == 0)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "File header size is zero");
+      goto out;
+    }
 
   /* Skip over padding */
   if (!g_input_stream_read_all (input,
diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c
index c617ccd..362f026 100644
--- a/src/ostree/ot-builtin-fsck.c
+++ b/src/ostree/ot-builtin-fsck.c
@@ -217,7 +217,10 @@ fsck_reachable_objects_from_commits (OtFsckData            *data,
           ot_clear_gvariant (&metadata);
           if (!ostree_repo_load_variant (data->repo, objtype,
                                          checksum, &metadata, error))
-            goto out;
+            {
+              g_prefix_error (error, "Loading metadata object %s: ", checksum);
+              goto out;
+            }
 
           if (objtype == OSTREE_OBJECT_TYPE_COMMIT)
             {
@@ -255,7 +258,10 @@ fsck_reachable_objects_from_commits (OtFsckData            *data,
           guint32 mode;
           if (!ostree_repo_load_file (data->repo, checksum, &input, &file_info,
                                       &xattrs, cancellable, error))
-            goto out;
+            {
+              g_prefix_error (error, "Loading file object %s: ", checksum);
+              goto out;
+            }
 
           mode = g_file_info_get_attribute_uint32 (file_info, "unix::mode");
           if (!ostree_validate_structureof_file_mode (mode, error))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]