- Fix the time_t problem on *64 ARCHS without introducing a possible

security risk by writing 8 bytes to a 4 byte declared variable.

  The first fix introduced a potential security problem.

PR:		ports/97681
Submitted by:	maintainer, Dan Lukes <dan_at_obluda.cz> (an initial patch)
This commit is contained in:
Sergey Matveychuk 2006-05-24 06:33:55 +00:00
parent 366cd5d141
commit ed14f324dd
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=163229
12 changed files with 216 additions and 56 deletions

View file

@ -8,7 +8,7 @@
PORTNAME= dhcp
PORTVERSION= 3.0.4
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history
@ -40,10 +40,6 @@ OPTIONS= DHCP_PARANOIA "add -user, -group and -chroot options" on \
.include <bsd.port.pre.mk>
.if ${ARCH} == "amd64" || ${ARCH} == "ia64" || ${ARCH} == "sparc64"
FORBIDDEN= the last fix for 64-bit platforms may cause security problems
.endif
.if ${SUBSYS} == server && defined(WITH_DHCP_LDAP)
# Based on patch from Brian Masney :
PATCH_SITES= http://www.newwave.net/~masneyb/:ldap \

View file

@ -9,15 +9,6 @@
#include <string.h>
#include <paths.h>
#include <errno.h>
@@ -82,7 +82,7 @@
/* Time stuff... */
#include <sys/time.h>
-#define TIME time_t
+#define TIME u_int32_t
#define GET_TIME(x) time ((x))
#define HAVE_SA_LEN
@@ -97,6 +97,10 @@
#define SOCKLEN_T int
#endif

View file

@ -0,0 +1,53 @@
--- server/dhcp.c.orig Wed Feb 22 23:43:27 2006
+++ server/dhcp.c Mon May 22 01:39:59 2006
@@ -2442,6 +2442,7 @@
offered_lease_time =
state -> offered_expiry - cur_time;
+ state -> expiry = 0;
putULong ((unsigned char *)&state -> expiry,
(unsigned long)offered_lease_time);
i = DHO_DHCP_LEASE_TIME;
@@ -2452,7 +2453,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> expiry,
- sizeof state -> expiry,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2463,6 +2464,7 @@
/* Renewal time is lease time * 0.5. */
offered_lease_time /= 2;
+ state -> renewal = 0;
putULong ((unsigned char *)&state -> renewal,
(unsigned long)offered_lease_time);
i = DHO_DHCP_RENEWAL_TIME;
@@ -2474,7 +2476,7 @@
if (make_const_data (&oc -> expression,
(unsigned char *)
&state -> renewal,
- sizeof state -> renewal,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2486,6 +2488,7 @@
/* Rebinding time is lease time * 0.875. */
offered_lease_time += (offered_lease_time / 2
+ offered_lease_time / 4);
+ state -> rebind = 0;
putULong ((unsigned char *)&state -> rebind,
(unsigned)offered_lease_time);
i = DHO_DHCP_REBINDING_TIME;
@@ -2496,7 +2499,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> rebind,
- sizeof state -> rebind,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,

View file

@ -8,7 +8,7 @@
PORTNAME= dhcp
PORTVERSION= 3.0.4
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history
@ -40,10 +40,6 @@ OPTIONS= DHCP_PARANOIA "add -user, -group and -chroot options" on \
.include <bsd.port.pre.mk>
.if ${ARCH} == "amd64" || ${ARCH} == "ia64" || ${ARCH} == "sparc64"
FORBIDDEN= the last fix for 64-bit platforms may cause security problems
.endif
.if ${SUBSYS} == server && defined(WITH_DHCP_LDAP)
# Based on patch from Brian Masney :
PATCH_SITES= http://www.newwave.net/~masneyb/:ldap \

View file

@ -9,15 +9,6 @@
#include <string.h>
#include <paths.h>
#include <errno.h>
@@ -82,7 +82,7 @@
/* Time stuff... */
#include <sys/time.h>
-#define TIME time_t
+#define TIME u_int32_t
#define GET_TIME(x) time ((x))
#define HAVE_SA_LEN
@@ -97,6 +97,10 @@
#define SOCKLEN_T int
#endif

View file

@ -0,0 +1,53 @@
--- server/dhcp.c.orig Wed Feb 22 23:43:27 2006
+++ server/dhcp.c Mon May 22 01:39:59 2006
@@ -2442,6 +2442,7 @@
offered_lease_time =
state -> offered_expiry - cur_time;
+ state -> expiry = 0;
putULong ((unsigned char *)&state -> expiry,
(unsigned long)offered_lease_time);
i = DHO_DHCP_LEASE_TIME;
@@ -2452,7 +2453,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> expiry,
- sizeof state -> expiry,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2463,6 +2464,7 @@
/* Renewal time is lease time * 0.5. */
offered_lease_time /= 2;
+ state -> renewal = 0;
putULong ((unsigned char *)&state -> renewal,
(unsigned long)offered_lease_time);
i = DHO_DHCP_RENEWAL_TIME;
@@ -2474,7 +2476,7 @@
if (make_const_data (&oc -> expression,
(unsigned char *)
&state -> renewal,
- sizeof state -> renewal,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2486,6 +2488,7 @@
/* Rebinding time is lease time * 0.875. */
offered_lease_time += (offered_lease_time / 2
+ offered_lease_time / 4);
+ state -> rebind = 0;
putULong ((unsigned char *)&state -> rebind,
(unsigned)offered_lease_time);
i = DHO_DHCP_REBINDING_TIME;
@@ -2496,7 +2499,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> rebind,
- sizeof state -> rebind,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,

View file

@ -8,7 +8,7 @@
PORTNAME= dhcp
PORTVERSION= 3.0.4
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history
@ -40,10 +40,6 @@ OPTIONS= DHCP_PARANOIA "add -user, -group and -chroot options" on \
.include <bsd.port.pre.mk>
.if ${ARCH} == "amd64" || ${ARCH} == "ia64" || ${ARCH} == "sparc64"
FORBIDDEN= the last fix for 64-bit platforms may cause security problems
.endif
.if ${SUBSYS} == server && defined(WITH_DHCP_LDAP)
# Based on patch from Brian Masney :
PATCH_SITES= http://www.newwave.net/~masneyb/:ldap \

View file

@ -9,15 +9,6 @@
#include <string.h>
#include <paths.h>
#include <errno.h>
@@ -82,7 +82,7 @@
/* Time stuff... */
#include <sys/time.h>
-#define TIME time_t
+#define TIME u_int32_t
#define GET_TIME(x) time ((x))
#define HAVE_SA_LEN
@@ -97,6 +97,10 @@
#define SOCKLEN_T int
#endif

View file

@ -0,0 +1,53 @@
--- server/dhcp.c.orig Wed Feb 22 23:43:27 2006
+++ server/dhcp.c Mon May 22 01:39:59 2006
@@ -2442,6 +2442,7 @@
offered_lease_time =
state -> offered_expiry - cur_time;
+ state -> expiry = 0;
putULong ((unsigned char *)&state -> expiry,
(unsigned long)offered_lease_time);
i = DHO_DHCP_LEASE_TIME;
@@ -2452,7 +2453,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> expiry,
- sizeof state -> expiry,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2463,6 +2464,7 @@
/* Renewal time is lease time * 0.5. */
offered_lease_time /= 2;
+ state -> renewal = 0;
putULong ((unsigned char *)&state -> renewal,
(unsigned long)offered_lease_time);
i = DHO_DHCP_RENEWAL_TIME;
@@ -2474,7 +2476,7 @@
if (make_const_data (&oc -> expression,
(unsigned char *)
&state -> renewal,
- sizeof state -> renewal,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2486,6 +2488,7 @@
/* Rebinding time is lease time * 0.875. */
offered_lease_time += (offered_lease_time / 2
+ offered_lease_time / 4);
+ state -> rebind = 0;
putULong ((unsigned char *)&state -> rebind,
(unsigned)offered_lease_time);
i = DHO_DHCP_REBINDING_TIME;
@@ -2496,7 +2499,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> rebind,
- sizeof state -> rebind,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,

View file

@ -8,7 +8,7 @@
PORTNAME= dhcp
PORTVERSION= 3.0.4
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_ISC}
MASTER_SITE_SUBDIR= dhcp dhcp/dhcp-3.0-history
@ -40,10 +40,6 @@ OPTIONS= DHCP_PARANOIA "add -user, -group and -chroot options" on \
.include <bsd.port.pre.mk>
.if ${ARCH} == "amd64" || ${ARCH} == "ia64" || ${ARCH} == "sparc64"
FORBIDDEN= the last fix for 64-bit platforms may cause security problems
.endif
.if ${SUBSYS} == server && defined(WITH_DHCP_LDAP)
# Based on patch from Brian Masney :
PATCH_SITES= http://www.newwave.net/~masneyb/:ldap \

View file

@ -9,15 +9,6 @@
#include <string.h>
#include <paths.h>
#include <errno.h>
@@ -82,7 +82,7 @@
/* Time stuff... */
#include <sys/time.h>
-#define TIME time_t
+#define TIME u_int32_t
#define GET_TIME(x) time ((x))
#define HAVE_SA_LEN
@@ -97,6 +97,10 @@
#define SOCKLEN_T int
#endif

View file

@ -0,0 +1,53 @@
--- server/dhcp.c.orig Wed Feb 22 23:43:27 2006
+++ server/dhcp.c Mon May 22 01:39:59 2006
@@ -2442,6 +2442,7 @@
offered_lease_time =
state -> offered_expiry - cur_time;
+ state -> expiry = 0;
putULong ((unsigned char *)&state -> expiry,
(unsigned long)offered_lease_time);
i = DHO_DHCP_LEASE_TIME;
@@ -2452,7 +2453,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> expiry,
- sizeof state -> expiry,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2463,6 +2464,7 @@
/* Renewal time is lease time * 0.5. */
offered_lease_time /= 2;
+ state -> renewal = 0;
putULong ((unsigned char *)&state -> renewal,
(unsigned long)offered_lease_time);
i = DHO_DHCP_RENEWAL_TIME;
@@ -2474,7 +2476,7 @@
if (make_const_data (&oc -> expression,
(unsigned char *)
&state -> renewal,
- sizeof state -> renewal,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,
@@ -2486,6 +2488,7 @@
/* Rebinding time is lease time * 0.875. */
offered_lease_time += (offered_lease_time / 2
+ offered_lease_time / 4);
+ state -> rebind = 0;
putULong ((unsigned char *)&state -> rebind,
(unsigned)offered_lease_time);
i = DHO_DHCP_REBINDING_TIME;
@@ -2496,7 +2499,7 @@
if (option_cache_allocate (&oc, MDL)) {
if (make_const_data (&oc -> expression,
(unsigned char *)&state -> rebind,
- sizeof state -> rebind,
+ 4,
0, 0, MDL)) {
oc -> option = dhcp_universe.options [i];
save_option (&dhcp_universe,