pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/security/sudo Let the compiler handle the alignement f...
details: https://anonhg.NetBSD.org/pkgsrc/rev/df280d931528
branches: trunk
changeset: 603293:df280d931528
user: martin <martin%pkgsrc.org@localhost>
date: Thu May 03 08:31:05 2012 +0000
description:
Let the compiler handle the alignement for cached passwd entries, fixes
a bus error on sparc (since 64 bit time_t).
diffstat:
security/sudo/Makefile | 4 +-
security/sudo/distinfo | 3 +-
security/sudo/patches/patch-pwutil.c | 64 ++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 3 deletions(-)
diffs (96 lines):
diff -r cd1cdd14dfc8 -r df280d931528 security/sudo/Makefile
--- a/security/sudo/Makefile Thu May 03 08:29:39 2012 +0000
+++ b/security/sudo/Makefile Thu May 03 08:31:05 2012 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.134 2012/03/14 14:20:38 wiz Exp $
+# $NetBSD: Makefile,v 1.135 2012/05/03 08:31:05 martin Exp $
#
DISTNAME= sudo-1.7.8p1
-PKGREVISION= 1
+PKGREVISION= 2
CATEGORIES= security
MASTER_SITES= http://www.sudo.ws/dist/ \
ftp://ftp.sudo.ws/pub/sudo/ \
diff -r cd1cdd14dfc8 -r df280d931528 security/sudo/distinfo
--- a/security/sudo/distinfo Thu May 03 08:29:39 2012 +0000
+++ b/security/sudo/distinfo Thu May 03 08:31:05 2012 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.75 2011/11/01 15:09:17 taca Exp $
+$NetBSD: distinfo,v 1.76 2012/05/03 08:31:05 martin Exp $
SHA1 (sudo-1.7.8p1.tar.gz) = e5d9016b7d3a4449b724483fe165dc13198ce44c
RMD160 (sudo-1.7.8p1.tar.gz) = a89e0c2d709cc8d8cbe4360f3e08d7459bca0a4c
@@ -7,3 +7,4 @@
SHA1 (patch-af) = 0dce4ebbc82ab644565f71e8f472c407ddbaabf5
SHA1 (patch-ag) = fe8409164b61bdb229ca81d391de96898436ea0b
SHA1 (patch-logging.c) = 26608d7423b77f71f17b37cc87f4b2e75978d7cb
+SHA1 (patch-pwutil.c) = 6bc092fea6cd9e5e4c734e392cc4bb6e724b23bb
diff -r cd1cdd14dfc8 -r df280d931528 security/sudo/patches/patch-pwutil.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/security/sudo/patches/patch-pwutil.c Thu May 03 08:31:05 2012 +0000
@@ -0,0 +1,64 @@
+$NetBSD: patch-pwutil.c,v 1.1 2012/05/03 08:31:05 martin Exp $
+
+# NetBSD uses 64bit time_t, even on 32bit architectures.
+# This makes struct passwd require 8 byte-alginement on, for example,
+# 32bit sparc. Curiously it all worked out naturally for sparc64 ;-)
+# To not add to the magic, let the compiler design proper alignement
+# by declaring a helper struct which holds the cache entry header as
+# well as struct passwd.
+
+--- pwutil.c.orig 2011-10-21 15:18:38.000000000 +0200
++++ pwutil.c 2012-05-03 10:05:28.000000000 +0200
+@@ -84,6 +84,16 @@
+ };
+
+ /*
++ * To give the compiler a chance to properly align things, we declare this
++ * dummy structure to ease our size/offset calculations.
++ */
++struct cache_and_passwd {
++ struct cache_item cache;
++ struct passwd pw;
++};
++
++
++/*
+ * Compare by uid.
+ */
+ static int
+@@ -144,6 +154,7 @@
+ size_t nsize, psize, csize, gsize, dsize, ssize, total;
+ struct cache_item *item;
+ struct passwd *newpw;
++ struct cache_and_passwd *cnp;
+
+ /* If shell field is empty, expand to _PATH_BSHELL. */
+ pw_shell = (pw->pw_shell == NULL || pw->pw_shell[0] == '\0')
+@@ -151,7 +162,7 @@
+
+ /* Allocate in one big chunk for easy freeing. */
+ nsize = psize = csize = gsize = dsize = ssize = 0;
+- total = sizeof(struct cache_item) + sizeof(struct passwd);
++ total = sizeof(struct cache_and_passwd);
+ FIELD_SIZE(pw, pw_name, nsize);
+ FIELD_SIZE(pw, pw_passwd, psize);
+ #ifdef HAVE_LOGIN_CAP_H
+@@ -168,15 +179,15 @@
+ /* Allocate space for struct item, struct passwd and the strings. */
+ if ((item = malloc(total)) == NULL)
+ return NULL;
+- cp = (char *) item + sizeof(struct cache_item);
++ cnp = (struct cache_and_passwd*)item;
+
+ /*
+ * Copy in passwd contents and make strings relative to space
+ * at the end of the buffer.
+ */
+- newpw = (struct passwd *) cp;
++ newpw = &cnp->pw;
+ memcpy(newpw, pw, sizeof(struct passwd));
+- cp += sizeof(struct passwd);
++ cp = (char*)&cnp[1];
+ FIELD_COPY(pw, newpw, pw_name, nsize);
+ FIELD_COPY(pw, newpw, pw_passwd, psize);
+ #ifdef HAVE_LOGIN_CAP_H
Home |
Main Index |
Thread Index |
Old Index