File 0028-dhclient6-unsigned-lifetimes-for-script-bsc-926159.patch of Package dhcp.1901

From a495d17bfbea5594d9589b60020eb951b280f5d6 Mon Sep 17 00:00:00 2001
From: Marius Tomaschewski <mt@suse.de>
Date: Wed, 29 Apr 2015 11:18:36 +0200
Subject: [PATCH 28/31] dhclient6: unsigned lifetimes for script (bsc#926159)

Address/IA lifetimes are all unsigned, don't turn into signed
(negative e.g. in infinite case) when passing them to scripts
and format timestamps as long to not break them on 64bit archs.

References: bsc#926159
Signed-off-by: Marius Tomaschewski <mt@suse.de>

diff --git a/client/dhc6.c b/client/dhc6.c
index 63cbb65..7d0bf9a 100644
--- a/client/dhc6.c
+++ b/client/dhc6.c
@@ -3926,20 +3926,20 @@ dhc6_marshall_values(const char *prefix, struct client_state *client,
 			client_envadd(client, prefix,
 				      "ip6_type", "temporary");
 		}
-		client_envadd(client, prefix, "life_starts", "%d",
-			      (int)(addr->starts));
-		client_envadd(client, prefix, "preferred_life", "%d",
-			      (int)(addr->preferred_life));
-		client_envadd(client, prefix, "max_life", "%d",
-			      (int)(addr->max_life));
+		client_envadd(client, prefix, "life_starts", "%ld",
+			     (long)(addr->starts));
+		client_envadd(client, prefix, "preferred_life", "%u",
+			      addr->preferred_life);
+		client_envadd(client, prefix, "max_life", "%u",
+			      addr->max_life);
 	}
 
 	/* ia fields. */
 	if (ia != NULL) {
 		client_envadd(client, prefix, "iaid", "%s",
 			      print_hex_1(4, ia->iaid, 12));
-		client_envadd(client, prefix, "starts", "%d",
-			      (int)(ia->starts));
+		client_envadd(client, prefix, "starts", "%ld",
+			      (long)(ia->starts));
 		client_envadd(client, prefix, "renew", "%u", ia->renew);
 		client_envadd(client, prefix, "rebind", "%u", ia->rebind);
 	}
diff --git a/client/dhclient.c b/client/dhclient.c
index 006ac4e..2fe95dc 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -3008,13 +3008,13 @@ write_client6_lease(struct client_state *client, struct dhc6_lease *lease,
 			return ISC_R_IOERROR;
 
 		if (ia->ia_type != D6O_IA_TA)
-			stat = fprintf(leaseFile, "    starts %d;\n"
+			stat = fprintf(leaseFile, "    starts %ld;\n"
 						  "    renew %u;\n"
 						  "    rebind %u;\n",
-				       (int)ia->starts, ia->renew, ia->rebind);
+				       (long)ia->starts, ia->renew, ia->rebind);
 		else
-			stat = fprintf(leaseFile, "    starts %d;\n",
-				       (int)ia->starts);
+			stat = fprintf(leaseFile, "    starts %ld;\n",
+				       (long)ia->starts);
 		if (stat <= 0)
 			return ISC_R_IOERROR;
 
@@ -3031,10 +3031,10 @@ write_client6_lease(struct client_state *client, struct dhc6_lease *lease,
 			if (stat <= 0)
 				return ISC_R_IOERROR;
 
-			stat = fprintf(leaseFile, "      starts %d;\n"
+			stat = fprintf(leaseFile, "      starts %ld;\n"
 						  "      preferred-life %u;\n"
 						  "      max-life %u;\n",
-				       (int)addr->starts, addr->preferred_life,
+				       (long)addr->starts, addr->preferred_life,
 				       addr->max_life);
 			if (stat <= 0)
 				return ISC_R_IOERROR;
@@ -3401,7 +3401,7 @@ void script_write_params (client, prefix, lease)
 				      universes [i],
 				      &es, client_option_envadd);
 	}
-	client_envadd (client, prefix, "expiry", "%d", (int)(lease -> expiry));
+	client_envadd (client, prefix, "expiry", "%ld", (long)(lease -> expiry));
 }
 
 /*
-- 
2.1.4
openSUSE Build Service is sponsored by