]> wimlib.net Git - wimlib/blobdiff - src/inode.c
libFuzzer: add encoding fuzzer
[wimlib] / src / inode.c
index 03db2fb1d9fba62e907c600e3ac5fd081189ec28..40fe5679a6a3eeac8f6799ee091ca74dea8b37a5 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 /*
- * Copyright (C) 2012, 2013, 2014, 2015 Eric Biggers
+ * Copyright (C) 2012-2018 Eric Biggers
  *
  * This file is free software; you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -21,7 +21,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public License
- * along with this file; if not, see http://www.gnu.org/licenses/.
+ * along with this file; if not, see https://www.gnu.org/licenses/.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -267,7 +267,7 @@ inode_add_stream(struct wim_inode *inode, int stream_type,
 {
        if (inode->i_num_streams >= 0xFFFF) {
                ERROR("Inode has too many streams! Path=\"%"TS"\"",
-                     inode_first_full_path(inode));
+                     inode_any_full_path(inode));
                errno = EFBIG;
                return NULL;
        }
@@ -485,14 +485,14 @@ int
 blob_not_found_error(const struct wim_inode *inode, const u8 *hash)
 {
        if (wimlib_print_errors) {
-               tchar hashstr[SHA1_HASH_SIZE * 2 + 1];
+               tchar hashstr[SHA1_HASH_STRING_LEN];
 
                sprint_hash(hash, hashstr);
 
                ERROR("\"%"TS"\": blob not found\n"
                      "        SHA-1 message digest of missing blob:\n"
                      "        %"TS"",
-                     inode_first_full_path(inode), hashstr);
+                     inode_any_full_path(inode), hashstr);
        }
        return WIMLIB_ERR_RESOURCE_NOT_FOUND;
 }
@@ -510,15 +510,25 @@ stream_blob(const struct wim_inode_stream *strm, const struct blob_table *table)
                return lookup_blob(table, strm->_stream_hash);
 }
 
-/* Return the SHA-1 message digest of the data of the specified stream, or a
- * void SHA-1 of all zeroes if the specified stream is empty.   */
+/*
+ * Return the SHA-1 message digest of the data of the specified stream, or a
+ * void SHA-1 of all zeroes if the specified stream is empty, or NULL if the
+ * specified stream is unhashed.  (Most callers ensure the stream cannot be
+ * unhashed.)
+ */
 const u8 *
 stream_hash(const struct wim_inode_stream *strm)
 {
-       if (strm->stream_resolved)
-               return strm->_stream_blob ? strm->_stream_blob->hash : zero_hash;
-       else
+       if (!strm->stream_resolved)
                return strm->_stream_hash;
+
+       if (!strm->_stream_blob)
+               return zero_hash;
+
+       if (strm->_stream_blob->unhashed)
+               return NULL;
+
+       return strm->_stream_blob->hash;
 }
 
 /*
@@ -557,7 +567,9 @@ inode_get_blob_for_unnamed_data_stream_resolved(const struct wim_inode *inode)
 /*
  * Return the SHA-1 message digest of the unnamed data stream of the inode, or a
  * void SHA-1 of all zeroes if the inode does not have an unnamed data stream or
- * if the inode's unnamed data stream is empty.
+ * if the inode's unnamed data stream is empty, or NULL if the inode's unnamed
+ * data stream is unhashed.  (Most callers ensure the stream cannot be
+ * unhashed.)
  */
 const u8 *
 inode_get_hash_of_unnamed_data_stream(const struct wim_inode *inode)