[openldap/f15] fix: segfault when LDIF input is not terminated by newline
jvcelak
jvcelak at fedoraproject.org
Tue Jun 28 09:27:38 UTC 2011
commit 4e157821e234097fba2e9d583111eaa50d9e49ce
Author: Jan Vcelak <jvcelak at redhat.com>
Date: Mon Jun 27 15:30:55 2011 +0200
fix: segfault when LDIF input is not terminated by newline
Resolves: #716858
openldap-segfault-ldif-nl-end.patch | 31 +++++++++++++++++++++++++++++++
openldap.spec | 2 ++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/openldap-segfault-ldif-nl-end.patch b/openldap-segfault-ldif-nl-end.patch
new file mode 100644
index 0000000..ecfc08e
--- /dev/null
+++ b/openldap-segfault-ldif-nl-end.patch
@@ -0,0 +1,31 @@
+commit 83814a220fb70db8344469dc3e2db5357b36fc5c
+Author: Jan Vcelak <jvcelak at redhat.com>
+Date: Mon Jun 20 17:31:57 2011 +0200
+
+ ITS#6947 Handle missing '\n' termination in LDIF input
+
+diff --git a/libraries/libldap/ldif.c b/libraries/libldap/ldif.c
+index 0ee7849..0bc35bb 100644
+--- a/libraries/liblutil/ldif.c
++++ b/libraries/liblutil/ldif.c
+@@ -842,11 +842,16 @@ ldif_read_record(
+
+ if ( fgets( line, sizeof( line ), lfp->fp ) == NULL ) {
+ stop = 1;
+- /* Add \n in case the file does not end with newline */
+- line[0] = '\n';
+- line[1] = '\0';
++ len = 0;
++ } else {
++ len = strlen( line );
++ }
++
++ if ( len == 0 || line[len-1] != '\n' ) {
++ /* Add \n in case the line/file does not end with newline */
++ line[len] = '\n';
++ line[++len] = '\0';
+ }
+- len = strlen( line );
+
+ if ( last_ch == '\n' ) {
+ (*lno)++;
diff --git a/openldap.spec b/openldap.spec
index 7e22250..1eb89da 100644
--- a/openldap.spec
+++ b/openldap.spec
@@ -34,6 +34,7 @@ Patch11: openldap-slapadd-hang.patch
Patch12: openldap-nss-cacertdir-soft-error.patch
Patch13: openldap-ldapexop-double-free.patch
Patch14: openldap-segfault-ldif-indent.patch
+Patch15: openldap-segfault-ldif-nl-end.patch
# patches for the evolution library (see README.evolution)
Patch200: openldap-evolution-ntlm.patch
@@ -140,6 +141,7 @@ pushd openldap-%{version}
%patch12 -p1 -b .nss-cacertdir-soft-error
%patch13 -p1 -b .ldapexop-double-free
%patch14 -p1 -b .segfault-ldif-indent
+%patch15 -p1 -b .segfault-ldif-nl-end
cp %{_datadir}/libtool/config/config.{sub,guess} build/
More information about the scm-commits
mailing list