On 03/23/2012 11:58 AM, Adam Tkac wrote:
On 03/22/2012 04:27 PM, Petr Spacek wrote:
this patch fixes wrong SOA updates during DNS zone dynamic update (via
nsupdate).

It fixes LDAP plugin part of BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=805871

Good catch, the patch looks fine for me, please check my comments and
then push it.

Regards, Adam


Incorrect SOA serial number format after IPA installation has to be
solved in IPA install scripts.

Petr^2 Spacek

bind-dyndb-ldap-pspacek-0013-Fix-SOA-record-update.patch

+#define MAX_SOANUM_LENGTH 10
What about defining this to 11? After that you can omit "+ 1" additions
below.
(10 + 1) applied.

- change[index].mod_values[0] = alloca(sizeof(soa.name) + 1); \
+ change[index].mod_values[0] = alloca((MAX_SOANUM_LENGTH +
1)*sizeof(char)); \
Although this is correct, I don't think that "*sizeof(char)" is needed,
please remove it.
I'm probably too paranoid  :-)


Recommended changes applied, pushed to master.

https://fedorahosted.org/bind-dyndb-ldap/changeset/709e352e52141eac346139666483b5c5f5acd713

Petr^2 Spacek
>From 709e352e52141eac346139666483b5c5f5acd713 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Fri, 23 Mar 2012 13:10:33 +0100
Subject: [PATCH] Fix SOA record update. Signed-off-by: Petr Spacek
 <pspa...@redhat.com>

---
 src/ldap_helper.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/ldap_helper.c b/src/ldap_helper.c
index da6b2f4..d0cde9d 100644
--- a/src/ldap_helper.c
+++ b/src/ldap_helper.c
@@ -47,6 +47,7 @@
 #include <isc/netaddr.h>
 #include <isc/parseint.h>
 #include <isc/timer.h>
+#include <isc/string.h>
 
 #include <alloca.h>
 #define LDAP_DEPRECATED 1
@@ -2172,6 +2173,7 @@ static isc_result_t
 modify_soa_record(ldap_connection_t *ldap_conn, const char *zone_dn,
 		  dns_rdata_t *rdata)
 {
+	isc_result_t result;
 	isc_mem_t *mctx = ldap_conn->mctx;
 	dns_rdata_soa_t soa;
 	LDAPMod change[5];
@@ -2180,13 +2182,16 @@ modify_soa_record(ldap_connection_t *ldap_conn, const char *zone_dn,
 		NULL
 	};
 
+/* all values in SOA record are isc_uint32_t, i.e. max. 2^32-1 */
+#define MAX_SOANUM_LENGTH (10 + 1)
 #define SET_LDAP_MOD(index, name) \
 	change[index].mod_op = LDAP_MOD_REPLACE; \
 	change[index].mod_type = "idnsSOA" #name; \
 	change[index].mod_values = alloca(2 * sizeof(char *)); \
-	change[index].mod_values[0] = alloca(sizeof(soa.name) + 1); \
+	change[index].mod_values[0] = alloca(MAX_SOANUM_LENGTH); \
 	change[index].mod_values[1] = NULL; \
-	snprintf(change[index].mod_values[0], sizeof(soa.name) + 1, "%d", soa.name)
+	CHECK(isc_string_printf(change[index].mod_values[0], \
+		MAX_SOANUM_LENGTH, "%u", soa.name));
 
 	dns_rdata_tostruct(rdata, (void *)&soa, mctx);
 
@@ -2198,8 +2203,12 @@ modify_soa_record(ldap_connection_t *ldap_conn, const char *zone_dn,
 
 	dns_rdata_freestruct((void *)&soa);
 
-	return ldap_modify_do(ldap_conn, zone_dn, changep, ISC_FALSE);
+	result = ldap_modify_do(ldap_conn, zone_dn, changep, ISC_FALSE);
+
+cleanup:
+	return result;
 
+#undef MAX_SOANUM_LENGTH
 #undef SET_LDAP_MOD
 }
 
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to