Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/pkg_install/dist/lib Avoid strict aliasing issu...



details:   https://anonhg.NetBSD.org/src/rev/62c946c4420a
branches:  trunk
changeset: 1013853:62c946c4420a
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Sep 07 00:36:53 2020 +0000

description:
Avoid strict aliasing issue by using a separate buffer..

diffstat:

 external/bsd/pkg_install/dist/lib/plist.c |  11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r b18b63b5587e -r 62c946c4420a external/bsd/pkg_install/dist/lib/plist.c
--- a/external/bsd/pkg_install/dist/lib/plist.c Mon Sep 07 00:33:08 2020 +0000
+++ b/external/bsd/pkg_install/dist/lib/plist.c Mon Sep 07 00:36:53 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plist.c,v 1.2 2017/04/20 13:18:23 joerg Exp $  */
+/*     $NetBSD: plist.c,v 1.3 2020/09/07 00:36:53 christos Exp $       */
 
 #if HAVE_CONFIG_H
 #include "config.h"
@@ -7,7 +7,7 @@
 #if HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #endif
-__RCSID("$NetBSD: plist.c,v 1.2 2017/04/20 13:18:23 joerg Exp $");
+__RCSID("$NetBSD: plist.c,v 1.3 2020/09/07 00:36:53 christos Exp $");
 
 /*
  * FreeBSD install - a package for the installation and maintainance
@@ -627,8 +627,10 @@
                                                }
                                                buf[SymlinkHeaderLen + cc] = 0x0;
                                                if (strcmp(buf, p->next->name) != 0) {
-                                                       if ((cc = readlink(&buf[SymlinkHeaderLen], &buf[SymlinkHeaderLen],
-                                                                 sizeof(buf) - SymlinkHeaderLen)) < 0) {
+                                                       char    tmp2[MaxPathSize];
+
+                                                       if ((cc = readlink(&buf[SymlinkHeaderLen], tmp2,
+                                                                 sizeof(tmp2))) < 0) {
                                                                printf("symlink %s is not same as recorded value, %s: %s\n",
                                                                    buf, Force ? "deleting anyway" : "not deleting", tmp);
                                                                if (!Force) {
@@ -636,6 +638,7 @@
                                                                        goto pkgdb_cleanup;
                                                                }
                                                        }
+                                                       memcpy(&buf[SymlinkHeaderLen], tmp2, cc);
                                                        buf[SymlinkHeaderLen + cc] = 0x0;
                                                        if (strcmp(buf, p->next->name) != 0) {
                                                                printf("symlink %s is not same as recorded value, %s: %s\n",



Home | Main Index | Thread Index | Old Index