pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/databases/kldap Passing non-POD types to variadic func...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c4511a16c158
branches:  trunk
changeset: 411691:c4511a16c158
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Tue Feb 18 16:49:13 2020 +0000

description:
Passing non-POD types to variadic functions is UB. Use plain C strings.

diffstat:

 databases/kldap/Makefile                              |   3 +-
 databases/kldap/distinfo                              |   6 +-
 databases/kldap/patches/patch-autotests_testkldap.cpp |  64 +++++++++++++++++++
 databases/kldap/patches/patch-src_ber.cpp             |  44 +++++++++++++
 databases/kldap/patches/patch-src_ber.h               |  15 ++++
 databases/kldap/patches/patch-src_ldapcontrol.cpp     |  22 ++++++
 6 files changed, 152 insertions(+), 2 deletions(-)

diffs (188 lines):

diff -r cd30d1935a82 -r c4511a16c158 databases/kldap/Makefile
--- a/databases/kldap/Makefile  Tue Feb 18 16:47:20 2020 +0000
+++ b/databases/kldap/Makefile  Tue Feb 18 16:49:13 2020 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.3 2020/02/02 02:34:40 markd Exp $
+# $NetBSD: Makefile,v 1.4 2020/02/18 16:49:13 joerg Exp $
 
 DISTNAME=      kldap-${KAPPSVER}
+PKGREVISION=   1
 CATEGORIES=    databases
 
 HOMEPAGE=      https://community.kde.org/KDE_PIM
diff -r cd30d1935a82 -r c4511a16c158 databases/kldap/distinfo
--- a/databases/kldap/distinfo  Tue Feb 18 16:47:20 2020 +0000
+++ b/databases/kldap/distinfo  Tue Feb 18 16:49:13 2020 +0000
@@ -1,6 +1,10 @@
-$NetBSD: distinfo,v 1.2 2020/02/02 02:34:40 markd Exp $
+$NetBSD: distinfo,v 1.3 2020/02/18 16:49:13 joerg Exp $
 
 SHA1 (kldap-19.12.1.tar.xz) = 1fee9a6dbe1b0bbe134d04bbdc96b25bbd470ca4
 RMD160 (kldap-19.12.1.tar.xz) = edbb09747c1e87d002952b1b19593cfb3ab89cbb
 SHA512 (kldap-19.12.1.tar.xz) = 48445a5bb2ee1e9a897d5306c8641933d8aa18dc34546b136e38d67b944a22760ac1651bbb4d5cbeb3647d005d299813e47b36e9c3ec7bc143a2443847b2622a
 Size (kldap-19.12.1.tar.xz) = 155468 bytes
+SHA1 (patch-autotests_testkldap.cpp) = 7994aba5bc9e45fd2ec1ebd3bf2e918fb912e560
+SHA1 (patch-src_ber.cpp) = be0bb86e83fb8c01b9a5c26cf9636d9590eb25e2
+SHA1 (patch-src_ber.h) = ae191eb21abf68197887b42a3250c7efc2067fca
+SHA1 (patch-src_ldapcontrol.cpp) = 9f91d9e6ae20bde896584986009fe18700addfef
diff -r cd30d1935a82 -r c4511a16c158 databases/kldap/patches/patch-autotests_testkldap.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/kldap/patches/patch-autotests_testkldap.cpp     Tue Feb 18 16:49:13 2020 +0000
@@ -0,0 +1,64 @@
+$NetBSD: patch-autotests_testkldap.cpp,v 1.1 2020/02/18 16:49:13 joerg Exp $
+
+--- autotests/testkldap.cpp.orig       2020-01-14 16:28:11.689663234 +0000
++++ autotests/testkldap.cpp
+@@ -89,37 +89,37 @@ void KLdapTest::testBer()
+ 
+     ainteger = 23543;
+ 
+-    ber1.printf(QStringLiteral("i"), ainteger);
+-    ber2.printf(QStringLiteral("o"), &aoctetString1);
+-    ber3.printf(QStringLiteral("O"), &aoctetString2);
+-    ber4.printf(QStringLiteral("s"), &aoctetString3);
+-    ber5.printf(QStringLiteral("{v}"), &alist1);
+-    ber6.printf(QStringLiteral("{V}"), &alist2);
+-    ber7.printf(QStringLiteral("oi{v}O"), &aoctetString1, ainteger, &alist2, &aoctetString2);
++    ber1.printf("i", ainteger);
++    ber2.printf("o", &aoctetString1);
++    ber3.printf("O", &aoctetString2);
++    ber4.printf("s", &aoctetString3);
++    ber5.printf("{v}", &alist1);
++    ber6.printf("{V}", &alist2);
++    ber7.printf("oi{v}O", &aoctetString1, ainteger, &alist2, &aoctetString2);
+ 
+     //test integer:
+     bber = ber1;
+-    bber.scanf(QStringLiteral("i"), &binteger);
++    bber.scanf("i", &binteger);
+     QCOMPARE(ainteger, binteger);
+ 
+     //test octet strings:
+     bber = ber2;
+-    bber.scanf(QStringLiteral("o"), &boctetString1);
++    bber.scanf("o", &boctetString1);
+     QCOMPARE(aoctetString1, boctetString1);
+     bber = ber3;
+-    bber.scanf(QStringLiteral("o"), &boctetString2);
++    bber.scanf("o", &boctetString2);
+     QCOMPARE(aoctetString2, boctetString2);
+     bber = ber4;
+-    bber.scanf(QStringLiteral("o"), &boctetString3);
++    bber.scanf("o", &boctetString3);
+     QCOMPARE(aoctetString3, boctetString3);
+ 
+     //test sequence of octet strings:
+     bber = ber5;
+-    bber.scanf(QStringLiteral("v"), &blist1);
++    bber.scanf("v", &blist1);
+     QCOMPARE(alist1, blist1);
+ 
+     bber = ber6;
+-    bber.scanf(QStringLiteral("v"), &blist2);
++    bber.scanf("v", &blist2);
+     QCOMPARE(alist2, blist2);
+ 
+     //complex tests
+@@ -129,7 +129,7 @@ void KLdapTest::testBer()
+     blist2.clear();
+ 
+     bber = ber7;
+-    bber.scanf(QStringLiteral("oivO"), &boctetString1, &binteger, &blist2, &boctetString2);
++    bber.scanf("oivO", &boctetString1, &binteger, &blist2, &boctetString2);
+     QCOMPARE(aoctetString1, boctetString1);
+     QCOMPARE(aoctetString2, boctetString2);
+     QCOMPARE(alist2, blist2);
diff -r cd30d1935a82 -r c4511a16c158 databases/kldap/patches/patch-src_ber.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/kldap/patches/patch-src_ber.cpp Tue Feb 18 16:49:13 2020 +0000
@@ -0,0 +1,44 @@
+$NetBSD: patch-src_ber.cpp,v 1.1 2020/02/18 16:49:13 joerg Exp $
+
+--- src/ber.cpp.orig   2020-01-14 16:17:11.814803692 +0000
++++ src/ber.cpp
+@@ -124,7 +124,7 @@ QByteArray Ber::flatten() const
+     return ret;
+ }
+ 
+-int Ber::printf(QString format, ...)
++int Ber::printf(const char *format, ...)
+ {
+     char fmt[2];
+     va_list args;
+@@ -132,8 +132,8 @@ int Ber::printf(QString format, ...)
+     fmt[1] = '\0';
+ 
+     int i = 0, ret = 0;
+-    while (i < format.length()) {
+-        fmt[0] = format[i].toLatin1();
++    while (format[i]) {
++        fmt[0] = format[i];
+         i++;
+         switch (fmt[0]) {
+         case 'b':
+@@ -229,7 +229,7 @@ int Ber::printf(QString format, ...)
+     return ret;
+ }
+ 
+-int Ber::scanf(QString format, ...)
++int Ber::scanf(const char *format, ...)
+ {
+     char fmt[2];
+     va_list args;
+@@ -237,8 +237,8 @@ int Ber::scanf(QString format, ...)
+     fmt[1] = '\0';
+ 
+     int i = 0, ret = 0;
+-    while (i < format.length()) {
+-        fmt[0] = format[i].toLatin1();
++    while (format[i]) {
++        fmt[0] = format[i];
+         i++;
+         switch (fmt[0]) {
+         case 'l':
diff -r cd30d1935a82 -r c4511a16c158 databases/kldap/patches/patch-src_ber.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/kldap/patches/patch-src_ber.h   Tue Feb 18 16:49:13 2020 +0000
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_ber.h,v 1.1 2020/02/18 16:49:13 joerg Exp $
+
+--- src/ber.h.orig     2020-01-14 16:17:30.291511893 +0000
++++ src/ber.h
+@@ -115,8 +115,8 @@ public:
+      *   </li>
+      * </ul>
+      */
+-    int printf(QString format, ...); // Passing by-value since it's used by va_start
+-    int scanf(QString format, ...);
++    int printf(const char *format, ...);
++    int scanf(const char *format, ...);
+     unsigned int peekTag(int &size);
+     unsigned int skipTag(int &size);
+ 
diff -r cd30d1935a82 -r c4511a16c158 databases/kldap/patches/patch-src_ldapcontrol.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/databases/kldap/patches/patch-src_ldapcontrol.cpp Tue Feb 18 16:49:13 2020 +0000
@@ -0,0 +1,22 @@
+$NetBSD: patch-src_ldapcontrol.cpp,v 1.1 2020/02/18 16:49:13 joerg Exp $
+
+--- src/ldapcontrol.cpp.orig   2020-01-14 16:22:02.256391951 +0000
++++ src/ldapcontrol.cpp
+@@ -123,7 +123,7 @@ int LdapControl::parsePageControl(QByteA
+ 
+     Ber ber(d->mValue);
+     int size;
+-    if (ber.scanf(QStringLiteral("{iO}"), &size, &cookie) == -1) {
++    if (ber.scanf("{iO}", &size, &cookie) == -1) {
+         return -1;
+     } else {
+         return size;
+@@ -135,7 +135,7 @@ LdapControl LdapControl::createPageContr
+     LdapControl control;
+     Ber ber;
+ 
+-    ber.printf(QStringLiteral("{iO}"), pagesize, &cookie);
++    ber.printf("{iO}", pagesize, &cookie);
+     control.setOid(QStringLiteral("1.2.840.113556.1.4.319"));
+     control.setValue(ber.flatten());
+     return control;



Home | Main Index | Thread Index | Old Index