pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/news/newsbeuter Avoid UB for variadic functions. Avoid...
details: https://anonhg.NetBSD.org/pkgsrc/rev/af0dc407ee1a
branches: trunk
changeset: 355936:af0dc407ee1a
user: joerg <joerg%pkgsrc.org@localhost>
date: Fri Dec 16 00:00:25 2016 +0000
description:
Avoid UB for variadic functions. Avoid unnecessary string copies.
diffstat:
news/newsbeuter/Makefile | 4 +-
news/newsbeuter/distinfo | 4 +-
news/newsbeuter/patches/patch-include_configcontainer.h | 20 ++++
news/newsbeuter/patches/patch-src_configcontainer.cpp | 77 +++++++++++++++++
4 files changed, 102 insertions(+), 3 deletions(-)
diffs (134 lines):
diff -r 1930b4ddd8d4 -r af0dc407ee1a news/newsbeuter/Makefile
--- a/news/newsbeuter/Makefile Thu Dec 15 23:58:18 2016 +0000
+++ b/news/newsbeuter/Makefile Fri Dec 16 00:00:25 2016 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.4 2016/12/04 05:17:39 ryoon Exp $
+# $NetBSD: Makefile,v 1.5 2016/12/16 00:00:25 joerg Exp $
DISTNAME= newsbeuter-2.9
-PKGREVISION= 3
+PKGREVISION= 4
CATEGORIES= news
MASTER_SITES= http://www.newsbeuter.org/downloads/
diff -r 1930b4ddd8d4 -r af0dc407ee1a news/newsbeuter/distinfo
--- a/news/newsbeuter/distinfo Thu Dec 15 23:58:18 2016 +0000
+++ b/news/newsbeuter/distinfo Fri Dec 16 00:00:25 2016 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.1 2016/05/24 09:27:09 leot Exp $
+$NetBSD: distinfo,v 1.2 2016/12/16 00:00:25 joerg Exp $
SHA1 (newsbeuter-2.9.tar.gz) = e0d61cda874ea9b77ed27f2edfea50a6ea471894
RMD160 (newsbeuter-2.9.tar.gz) = b93adbf5305191c40f3e4b2d770d9984bb7c32e3
@@ -6,4 +6,6 @@
Size (newsbeuter-2.9.tar.gz) = 432763 bytes
SHA1 (patch-Makefile) = 53d6ddfa518a1a371428afdf36745028530b30de
SHA1 (patch-config.sh) = e5d4adf96cae46c8febf818ff03b4f598a865945
+SHA1 (patch-include_configcontainer.h) = 54c7756cf29550c60181c3cdf52e9178183b78ed
+SHA1 (patch-src_configcontainer.cpp) = 3f799235a4d36acbfa3938ed68abd48776eb143f
SHA1 (patch-src_controller.cpp) = 927b11064deac38acbb577aa0d3f750f72c0e55a
diff -r 1930b4ddd8d4 -r af0dc407ee1a news/newsbeuter/patches/patch-include_configcontainer.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/news/newsbeuter/patches/patch-include_configcontainer.h Fri Dec 16 00:00:25 2016 +0000
@@ -0,0 +1,20 @@
+$NetBSD: patch-include_configcontainer.h,v 1.1 2016/12/16 00:00:25 joerg Exp $
+
+Avoid unnecessary string copies.
+
+Passing non-POD types to variadic functions is UB, so use C++11 rvalues
+and proper typing.
+
+--- include/configcontainer.h.orig 2016-12-15 14:37:54.279263729 +0000
++++ include/configcontainer.h
+@@ -8,8 +8,8 @@ namespace newsbeuter {
+
+ struct configdata {
+ enum configdata_type { INVALID, BOOL, INT, STR, PATH, ALIAS, ENUM };
+- configdata(std::string v = "", configdata_type t = INVALID, bool m = false) : value(v), default_value(v), type(t), multi_option(m) { }
+- configdata(std::string v, ...);
++ configdata(const std::string &v = "", configdata_type t = INVALID, bool m = false) : value(v), default_value(v), type(t), multi_option(m) { }
++ configdata(const std::string &v, std::set<std::string> &&);
+ std::string value;
+ std::string default_value;
+ configdata_type type;
diff -r 1930b4ddd8d4 -r af0dc407ee1a news/newsbeuter/patches/patch-src_configcontainer.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/news/newsbeuter/patches/patch-src_configcontainer.cpp Fri Dec 16 00:00:25 2016 +0000
@@ -0,0 +1,77 @@
+$NetBSD: patch-src_configcontainer.cpp,v 1.1 2016/12/16 00:00:25 joerg Exp $
+
+Passing non-POD types to variadic functions is UB, so use C++11 rvalues
+and proper typing.
+
+--- src/configcontainer.cpp.orig 2016-12-15 14:37:26.527419424 +0000
++++ src/configcontainer.cpp
+@@ -15,20 +15,8 @@
+
+ namespace newsbeuter {
+
+-configdata::configdata(std::string v, ...) : value(v), default_value(v), type(ENUM) {
+- va_list ap;
+- va_start(ap, v);
+-
+- const char * arg;
+-
+- do {
+- arg = va_arg(ap, const char *);
+- if (arg) {
+- enum_values.insert(arg);
+- }
+- } while (arg != NULL);
+-
+- va_end(ap);
++configdata::configdata(const std::string &v, std::set<std::string> &&enumv) : value(v), default_value(v), type(ENUM) {
++ enum_values = std::move(enumv);
+ }
+
+ configcontainer::configcontainer() {
+@@ -51,8 +39,8 @@ configcontainer::configcontainer() {
+ config_data["cache-file"] = configdata("", configdata::PATH);
+ config_data["proxy"] = configdata("", configdata::STR);
+ config_data["proxy-auth"] = configdata("", configdata::STR);
+- config_data["proxy-auth-method"] = configdata("any", "any", "basic", "digest", "digest_ie", "gssnegotiate", "ntlm", "anysafe", NULL);
+- config_data["http-auth-method"] = configdata("any", "any", "basic", "digest", "digest_ie", "gssnegotiate", "ntlm", "anysafe", NULL);
++ config_data["proxy-auth-method"] = configdata("any", std::set<std::string>({"any", "basic", "digest", "digest_ie", "gssnegotiate", "ntlm", "anysafe"}));
++ config_data["http-auth-method"] = configdata("any", std::set<std::string>({"any", "basic", "digest", "digest_ie", "gssnegotiate", "ntlm", "anysafe"}));
+ config_data["confirm-exit"] = configdata("no", configdata::BOOL);
+ config_data["error-log"] = configdata("", configdata::PATH);
+ config_data["notify-screen"] = configdata("no", configdata::BOOL);
+@@ -62,7 +50,7 @@ configcontainer::configcontainer() {
+ config_data["notify-program"] = configdata("", configdata::PATH);
+ config_data["notify-format"] = configdata(_("newsbeuter: finished reload, %f unread feeds (%n unread articles total)"), configdata::STR);
+ config_data["datetime-format"] = configdata("%b %d", configdata::STR);
+- config_data["urls-source"] = configdata("local", "local", "opml", "oldreader", "ttrss", "newsblur", "feedhq", NULL); // enum
++ config_data["urls-source"] = configdata("local", std::set<std::string>({"local", "opml", "oldreader", "ttrss", "newsblur", "feedhq"})); // enum
+ config_data["bookmark-cmd"] = configdata("", configdata::STR);
+ config_data["opml-url"] = configdata("", configdata::STR, true);
+ config_data["html-renderer"] = configdata("internal", configdata::PATH);
+@@ -90,7 +78,7 @@ configcontainer::configcontainer() {
+ config_data["history-limit"] = configdata("100", configdata::INT);
+ config_data["prepopulate-query-feeds"] = configdata("false", configdata::BOOL);
+ config_data["goto-first-unread"] = configdata("true", configdata::BOOL);
+- config_data["proxy-type"] = configdata("http", "http", "socks4", "socks4a", "socks5", NULL); // enum
++ config_data["proxy-type"] = configdata("http", std::set<std::string>({"http", "socks4", "socks4a", "socks5"})); // enum
+ config_data["oldreader-login"] = configdata("", configdata::STR);
+ config_data["oldreader-password"] = configdata("", configdata::STR);
+ config_data["oldreader-passwordfile"] = configdata("", configdata::PATH);
+@@ -106,7 +94,7 @@ configcontainer::configcontainer() {
+ config_data["feedhq-show-special-feeds"] = configdata("true", configdata::BOOL);
+ config_data["feedhq-min-items"] = configdata("20", configdata::INT);
+ config_data["feedhq-url"] = configdata("https://feedhq.org/", configdata::STR);
+- config_data["ignore-mode"] = configdata("download", "download", "display", NULL); // enum
++ config_data["ignore-mode"] = configdata("download", std::set<std::string>({"download", "display"})); // enum
+ config_data["max-download-speed"] = configdata("0", configdata::INT);
+ config_data["cookie-cache"] = configdata("", configdata::PATH);
+ config_data["download-full-page"] = configdata("false", configdata::BOOL);
+@@ -115,7 +103,7 @@ configcontainer::configcontainer() {
+ config_data["ttrss-password"] = configdata("", configdata::STR);
+ config_data["ttrss-passwordfile"] = configdata("", configdata::PATH);
+ config_data["ttrss-url"] = configdata("", configdata::STR);
+- config_data["ttrss-mode"] = configdata("multi", "single", "multi", NULL); // enum
++ config_data["ttrss-mode"] = configdata("multi", std::set<std::string>({"single", "multi"})); // enum
+ config_data["ttrss-flag-star"] = configdata("", configdata::STR);
+ config_data["ttrss-flag-publish"] = configdata("", configdata::STR);
+ config_data["newsblur-login"] = configdata("", configdata::STR);
Home |
Main Index |
Thread Index |
Old Index