]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Merge pull request #2694 from stoeckmann/cleanups
authorTim Kientzle <kientzle@acm.org>
Sat, 12 Jul 2025 04:06:20 +0000 (21:06 -0700)
committerMartin Matuska <martin@matuska.de>
Wed, 10 Sep 2025 08:19:09 +0000 (10:19 +0200)
Perform various cleanups

(cherry picked from commit 267042ebc7de8e4972d43d0c02433184649c1d4f)

SECURITY.md
libarchive/archive_cryptor_private.h
libarchive/archive_read.c
libarchive/archive_read_support_format_rar.c
libarchive/archive_read_support_format_tar.c
libarchive/archive_string.c
libarchive/archive_string_sprintf.c
libarchive/archive_write_set_format_mtree.c

index 6ca188b603fe13b3d4fa96467f31bb928dad2e13..f2f60e792a574a20dd2f0543d512e54e63e0930d 100644 (file)
@@ -16,4 +16,4 @@ Please provide the following information in your report:
 - How to reproduce the issue
 
 This project is maintained by volunteers on a reasonable-effort basis. As such, we ask
-that you give me 90 days to work on a fix before public exposure.
+that you give us 90 days to work on a fix before public exposure.
index 573a617e1f06c5bf9ae1e972c9bff7cc5f52ec0b..1dbc5c17a01aca4cb114907aff5270d2e12a77e2 100644 (file)
@@ -43,7 +43,7 @@ int __libarchive_cryptor_build_hack(void);
 #ifdef __APPLE__
 # include <AvailabilityMacros.h>
 # if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-#  define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
+#  define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto 1
 # endif
 #endif
 
index ea58c6ed0123c479ab2767799f30fd9a0ac60f30..c9b9d5981516639357e873814eea77a8112c914a 100644 (file)
@@ -575,8 +575,7 @@ choose_filters(struct archive_read *a)
                        return (ARCHIVE_OK);
                }
 
-               filter
-                   = calloc(1, sizeof(*filter));
+               filter = calloc(1, sizeof(*filter));
                if (filter == NULL)
                        return (ARCHIVE_FATAL);
                filter->bidder = best_bidder;
index 04dff5b6c3a34379af8e0a494de161995f00b286..9b401c00ba346ce8050959d49716b3367e6534d4 100644 (file)
@@ -1453,7 +1453,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
     return (ARCHIVE_FATAL);
 #endif
   }
-  /* If no CRC error, Go on parsing File Header. */
+  /* If no CRC error, go on parsing File Header. */
   p = h;
   endp = p + header_size - 7;
   memcpy(&file_header, p, sizeof(file_header));
@@ -2366,8 +2366,8 @@ parse_codes(struct archive_read *a)
         return (ARCHIVE_FATAL);
       }
 
-      /* Make sure ppmd7_contest is freed before Ppmd7_Construct
-       * because reading a broken file cause this abnormal sequence. */
+      /* Make sure ppmd7_context is freed before Ppmd7_Construct
+       * because reading a broken file causes this abnormal sequence. */
       __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
 
       rar->bytein.a = a;
index 0c87bc6d732ff025c9f62e87bda3c3d8956865f7..cb5344d6052616ff7ac651348b06aeb82b69ff2f 100644 (file)
@@ -1255,7 +1255,7 @@ read_bytes_to_string(struct archive_read *a,
        const void *src;
 
        /* Fail if we can't make our buffer big enough. */
-       if (archive_string_ensure(as, (size_t)size+1) == NULL) {
+       if (archive_string_ensure(as, size + 1) == NULL) {
                archive_set_error(&a->archive, ENOMEM,
                    "No memory");
                return (ARCHIVE_FATAL);
@@ -1272,9 +1272,9 @@ read_bytes_to_string(struct archive_read *a,
                *unconsumed = 0;
                return (ARCHIVE_FATAL);
        }
-       memcpy(as->s, src, (size_t)size);
+       memcpy(as->s, src, size);
        as->s[size] = '\0';
-       as->length = (size_t)size;
+       as->length = size;
        *unconsumed += size;
        return (ARCHIVE_OK);
 }
index 7437715f91226f758b0ead507115adcd9cf6f8f0..3bb978335eb876a635d93cb21a96d285fe9dcffe 100644 (file)
@@ -2015,7 +2015,7 @@ archive_strncat_l(struct archive_string *as, const void *_p, size_t n,
        /* We must allocate memory even if there is no data for conversion
         * or copy. This simulates archive_string_append behavior. */
        if (length == 0) {
-               int tn = 1;
+               size_t tn = 1;
                if (sc != NULL && (sc->flag & SCONV_TO_UTF16))
                        tn = 2;
                if (archive_string_ensure(as, as->length + tn) == NULL)
@@ -2752,7 +2752,8 @@ archive_string_append_unicode(struct archive_string *as, const void *_p,
        char *p, *endp;
        uint32_t uc;
        size_t w;
-       int n, ret = 0, ts, tm;
+       size_t ts, tm;
+       int n, ret = 0;
        int (*parse)(uint32_t *, const char *, size_t);
        size_t (*unparse)(char *, size_t, uint32_t);
 
index 1c5910e0b2d350c0ca7eb5efa75c18b76203aecc..69b0cdcd83d514619488a2d650111d0827bd80fb 100644 (file)
@@ -146,7 +146,7 @@ archive_string_vsprintf(struct archive_string *as, const char *fmt,
                        case 'z': s = va_arg(ap, ssize_t); break;
                        default:  s = va_arg(ap, int); break;
                        }
-                       append_int(as, s, 10);
+                       append_int(as, s, 10);
                        break;
                case 's':
                        switch(long_flag) {
index 02fbb2d2f5558167049f7a408a6bb3897f8b833c..8131574c8da2b0b36431794ada9647aa1bfb7248 100644 (file)
@@ -1927,7 +1927,7 @@ mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file,
        }
 
        /*
-        * Find out the position which points the last position of
+        * Find out the position which points to the last position of
         * path separator('/').
         */
        slash = NULL;
@@ -2024,7 +2024,7 @@ mtree_entry_add_child_tail(struct mtree_entry *parent,
 }
 
 /*
- * Find a entry from a parent entry with the name.
+ * Find an entry from a parent entry with given name.
  */
 static struct mtree_entry *
 mtree_entry_find_child(struct mtree_entry *parent, const char *child_name)
@@ -2148,10 +2148,10 @@ mtree_entry_tree_add(struct archive_write *a, struct mtree_entry **filep)
 
                /* Find next sub directory. */
                if (!np->dir_info) {
-                       /* NOT Directory! */
+                       /* NOT a directory! */
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_MISC,
-                           "`%s' is not directory, we cannot insert `%s' ",
+                           "`%s' is not directory, we cannot insert `%s' ",
                            np->pathname.s, file->pathname.s);
                        return (ARCHIVE_FAILED);
                }
@@ -2243,10 +2243,7 @@ mtree_entry_tree_add(struct archive_write *a, struct mtree_entry **filep)
        }
 
 same_entry:
-       /*
-        * We have already has the entry the filename of which is
-        * the same.
-        */
+       /* We already have an entry with same filename. */
        r = mtree_entry_exchange_same_entry(a, np, file);
        if (r < ARCHIVE_WARN)
                return (r);
@@ -2264,13 +2261,13 @@ mtree_entry_exchange_same_entry(struct archive_write *a, struct mtree_entry *np,
 
        if ((np->mode & AE_IFMT) != (file->mode & AE_IFMT)) {
                archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-                   "Found duplicate entries `%s' and its file type is "
-                   "different",
+                   "Found duplicate entries for `%s' with "
+                   "differing file types.",
                    np->pathname.s);
                return (ARCHIVE_FAILED);
        }
 
-       /* Update the existent mtree entry's attributes by the new one's. */
+       /* Update the existing mtree entry's attributes by the new one's. */
        archive_string_empty(&np->symlink);
        archive_string_concat(&np->symlink, &file->symlink);
        archive_string_empty(&np->uname);