Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/libarchive/dist/libarchive Avoid NULL pointer a...



details:   https://anonhg.NetBSD.org/src/rev/6c0dffdc60c0
branches:  trunk
changeset: 849274:6c0dffdc60c0
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Feb 25 09:01:25 2020 +0000

description:
Avoid NULL pointer arithmetic

Cherry-pick upstream patch:

>From ec5b86b48e99c5501374b01606f1ccdae6a8a93e Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski <n54%gmx.com@localhost>
Date: Mon, 24 Feb 2020 22:58:00 +0100
Subject: [PATCH] archive_read.c: silence UBSan warning about undefined
 behavior

Fixes #1335

https://github.com/libarchive/libarchive/commit/ec5b86b48e99c5501374b01606f1ccdae6a8a93e.patch

diffstat:

 external/bsd/libarchive/dist/libarchive/archive_read.c |  17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diffs (28 lines):

diff -r 0664cef75524 -r 6c0dffdc60c0 external/bsd/libarchive/dist/libarchive/archive_read.c
--- a/external/bsd/libarchive/dist/libarchive/archive_read.c    Tue Feb 25 08:05:24 2020 +0000
+++ b/external/bsd/libarchive/dist/libarchive/archive_read.c    Tue Feb 25 09:01:25 2020 +0000
@@ -891,15 +891,16 @@
                        len = a->read_data_remaining;
                        if (len > s)
                                len = s;
-                       if (len)
+                       if (len) {
                                memcpy(dest, a->read_data_block, len);
-                       s -= len;
-                       a->read_data_block += len;
-                       a->read_data_remaining -= len;
-                       a->read_data_output_offset += len;
-                       a->read_data_offset += len;
-                       dest += len;
-                       bytes_read += len;
+                               s -= len;
+                               a->read_data_block += len;
+                               a->read_data_remaining -= len;
+                               a->read_data_output_offset += len;
+                               a->read_data_offset += len;
+                               dest += len;
+                               bytes_read += len;
+                       }
                }
        }
        a->read_data_is_posix_read = 0;



Home | Main Index | Thread Index | Old Index