NEWS | 10 ++++++++++ configure.ac | 2 +- src/conv/raw/cdr2raw.cpp | 17 +++++++++++++++++ src/conv/raw/cmx2raw.cpp | 17 +++++++++++++++++ src/conv/svg/cdr2xhtml.cpp | 19 ++++++++++++++++++- src/conv/svg/cmx2xhtml.cpp | 19 ++++++++++++++++++- src/conv/text/cdr2text.cpp | 19 ++++++++++++++++++- src/conv/text/cmx2text.cpp | 19 ++++++++++++++++++- src/lib/CDRParser.cpp | 8 ++++---- src/lib/CMXParser.cpp | 5 +++++ 10 files changed, 126 insertions(+), 9 deletions(-)
New commits: commit cd98b72f3293c4fd81bdf51f7ca3f347baa52536 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 19:16:44 2015 +0100 coverity#1219668 untrusted loop bound Change-Id: I1d493b4c6d79f16c5ed5d68f23efd4b14e85da7a diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 36697f5..2351925 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -2668,7 +2668,7 @@ void libcdr::CDRParser::readStlt(librevenge::RVNGInputStream *input, unsigned le input->seek(784 * static_cast<long>(numTabs), librevenge::RVNG_SEEK_CUR); unsigned numBullets = readU32(input); CDR_DEBUG_MSG(("CDRParser::readStlt numBullets 0x%x\n", numBullets)); - for (i=0; i<numBullets; ++i) + for (i=0; i<numBullets && getRemainingLength(input) >= 16; ++i) { input->seek(40, librevenge::RVNG_SEEK_CUR); if (m_version > 1300) commit 525cd4a1a868bbf29c511ab00669518aa9818073 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 19:14:35 2015 +0100 coverity#1219658 untrusted loop bound Change-Id: Ibbe274f8ef136a42f290c41806224f6f6f93dcfb diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 630cf33..36697f5 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -2914,7 +2914,7 @@ void libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le num4 = readU32(input); } - for (unsigned j = 0; j < num4; ++j) + for (unsigned j = 0; j < num4 && getRemainingLength(input) >= 14; ++j) { unsigned stlId = readU32(input); if (m_version >= 1300 && num) commit c6ef8e3f7ca896b3be34c29e4bb8cee1deed4026 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 19:12:16 2015 +0100 coverity#1219657 untrusted loop bound Change-Id: I8fdc5ec1b1c02124594faa845b89c851307499ba diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index e9b4a19..630cf33 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -3150,7 +3150,7 @@ void libcdr::CDRParser::readTxsm6(librevenge::RVNGInputStream *input) unsigned numSt = readU32(input); unsigned i = 0; std::map<unsigned, CDRCharacterStyle> charStyles; - for (; i<numSt; ++i) + for (; i<numSt && getRemainingLength(input) >= 58; ++i) { CDRCharacterStyle charStyle; unsigned char flag = readU8(input); commit 5b43f6dabdf65be376de3ece7ab24fd7a5e94b83 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 19:10:16 2015 +0100 coverity#1219656 untrusted loop bound Change-Id: I949c0bc68aec676f0bff78d284738b6e384f2973 diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index fa54117..e9b4a19 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -3220,7 +3220,7 @@ void libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input) unsigned numSt = readU16(input); unsigned i = 0; std::map<unsigned, CDRCharacterStyle> charStyles; - for (; i<numSt; ++i) + for (; i<numSt && getRemainingLength(input) >= 34; ++i) { CDRCharacterStyle charStyle; unsigned char flag = readU8(input); commit 776ce0dfcc23cead3e57ee781e924bac4eee74d0 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 19:00:21 2015 +0100 avoid reallocations Change-Id: If01ca063b2f29ccf8d3ecf473e7d351c5b653bb5 diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp index e876071..c94e027 100644 --- a/src/lib/CMXParser.cpp +++ b/src/lib/CMXParser.cpp @@ -363,6 +363,8 @@ void libcdr::CMXParser::readPolyCurve(librevenge::RVNGInputStream *input) pointNum = readU16(input); if (pointNum > getRemainingLength(input) / (2 * 4 + 1)) pointNum = getRemainingLength(input) / (2 * 4 + 1); + points.reserve(pointNum); + pointTypes.reserve(pointNum); for (unsigned i = 0; i < pointNum; ++i) { std::pair<double, double> point; commit 5f23be87e2b13319a7751f25ce3c88165a52bb9d Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 18:59:31 2015 +0100 coverity#1219652 untrusted loop bound Change-Id: I9a9c6406b5e2ed2616075e97001701bb45c4ccd2 diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp index 68b0e92..e876071 100644 --- a/src/lib/CMXParser.cpp +++ b/src/lib/CMXParser.cpp @@ -361,6 +361,8 @@ void libcdr::CMXParser::readPolyCurve(librevenge::RVNGInputStream *input) break; case CMX_Tag_PolyCurve_PointList: pointNum = readU16(input); + if (pointNum > getRemainingLength(input) / (2 * 4 + 1)) + pointNum = getRemainingLength(input) / (2 * 4 + 1); for (unsigned i = 0; i < pointNum; ++i) { std::pair<double, double> point; commit 6f28e50debdf1f0a44f5fa7ed7e43a6d50b20e84 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 18:55:41 2015 +0100 add missing break Change-Id: I26f64966bb510588610c3f48770e3cf6636aa638 diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp index 8c6eb6c..68b0e92 100644 --- a/src/lib/CMXParser.cpp +++ b/src/lib/CMXParser.cpp @@ -370,6 +370,7 @@ void libcdr::CMXParser::readPolyCurve(librevenge::RVNGInputStream *input) } for (unsigned j = 0; j < pointNum; ++j) pointTypes.push_back(readU8(input, m_bigEndian)); + break; default: break; } commit af5ef20d8a0ac1c7cae2bc493156d299f246b214 Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 18:26:08 2015 +0100 prepare for a release Change-Id: Id180c188c4c2675ab96417d1b4f2ea8f0052eae5 diff --git a/NEWS b/NEWS index 61152a5..1f327d7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +libcdr 0.1.2 + +* Fix various crashes and hangs when reading broken files found with the + help of american-fuzzy-lop. +* Fix build with boost 1.59. (rhbz#1258127) +* Fix various problems detected by Coverity. +* Do not drop empty text lines. (tdf#67873) +* Make --help output of all command line tools more help2man-friendly. +* Several other small improvements. + libcdr 0.1.1 * Fix several problems found by Coverity. diff --git a/configure.ac b/configure.ac index b6285ab..0d57fe2 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_PREREQ([2.65]) # ==================== m4_define([libcdr_version_major],[0]) m4_define([libcdr_version_minor],[1]) -m4_define([libcdr_version_micro],[1]) +m4_define([libcdr_version_micro],[2]) m4_define([libcdr_version],[libcdr_version_major.libcdr_version_minor.libcdr_version_micro]) # ============= commit b2e5cbf18b4eb690fb2704bfaa3215075863b23c Author: David Tardon <dtar...@redhat.com> Date: Fri Dec 25 18:52:08 2015 +0100 make help output even more help2man-friendly Change-Id: I6dbe0ddcf67b91e67c2427cfa78c271f77a56433 diff --git a/src/conv/raw/cdr2raw.cpp b/src/conv/raw/cdr2raw.cpp index 1b68a29..c5217ba 100644 --- a/src/conv/raw/cdr2raw.cpp +++ b/src/conv/raw/cdr2raw.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <librevenge/librevenge.h> @@ -14,6 +18,10 @@ #include <librevenge-stream/librevenge-stream.h> #include <libcdr/libcdr.h> +#ifndef VERSION +#define VERSION "UNKNOWN VERSION" +#endif + namespace { @@ -26,11 +34,18 @@ int printUsage() printf("Options:\n"); printf("\t--callgraph display the call graph nesting level\n"); printf("\t--help show this help message\n"); + printf("\t--version show version information and exit\n"); printf("\n"); printf("Report bugs to <https://bugs.documentfoundation.org/>.\n"); return -1; } +int printVersion() +{ + printf("cdr2raw " VERSION "\n"); + return 0; +} + } // anonymous namespace int main(int argc, char *argv[]) @@ -45,6 +60,8 @@ int main(int argc, char *argv[]) { if (!strcmp(argv[i], "--callgraph")) printIndentLevel = true; + else if (!strcmp(argv[i], "--version")) + return printVersion(); else if (!file && strncmp(argv[i], "--", 2)) file = argv[i]; else diff --git a/src/conv/raw/cmx2raw.cpp b/src/conv/raw/cmx2raw.cpp index 63d2f7a..62223cf 100644 --- a/src/conv/raw/cmx2raw.cpp +++ b/src/conv/raw/cmx2raw.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <librevenge/librevenge.h> @@ -14,6 +18,10 @@ #include <librevenge-stream/librevenge-stream.h> #include <libcdr/libcdr.h> +#ifndef VERSION +#define VERSION "UNKNOWN VERSION" +#endif + namespace { @@ -26,11 +34,18 @@ int printUsage() printf("Options:\n"); printf("\t--callgraph display the call graph nesting level\n"); printf("\t--help show this help message\n"); + printf("\t--version show version information and exit\n"); printf("\n"); printf("Report bugs to <https://bugs.documentfoundation.org/>.\n"); return -1; } +int printVersion() +{ + printf("cmx2raw " VERSION "\n"); + return 0; +} + } // anonymous namespace int main(int argc, char *argv[]) @@ -45,6 +60,8 @@ int main(int argc, char *argv[]) { if (!strcmp(argv[i], "--callgraph")) printIndentLevel = true; + else if (!strcmp(argv[i], "--version")) + return printVersion(); else if (!file && strncmp(argv[i], "--", 2)) file = argv[i]; else diff --git a/src/conv/svg/cdr2xhtml.cpp b/src/conv/svg/cdr2xhtml.cpp index ef68dde..082926f 100644 --- a/src/conv/svg/cdr2xhtml.cpp +++ b/src/conv/svg/cdr2xhtml.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <iostream> #include <sstream> #include <stdio.h> @@ -16,6 +20,10 @@ #include <librevenge-stream/librevenge-stream.h> #include <libcdr/libcdr.h> +#ifndef VERSION +#define VERSION "UNKNOWN VERSION" +#endif + namespace { @@ -27,11 +35,18 @@ int printUsage() printf("\n"); printf("Options:\n"); printf("\t--help show this help message\n"); + printf("\t--version show version information and exit\n"); printf("\n"); printf("Report bugs to <https://bugs.documentfoundation.org/>.\n"); return -1; } +int printVersion() +{ + printf("cdr2xhtml " VERSION "\n"); + return 0; +} + } // anonymous namespace int main(int argc, char *argv[]) @@ -43,7 +58,9 @@ int main(int argc, char *argv[]) for (int i = 1; i < argc; i++) { - if (!file && strncmp(argv[i], "--", 2)) + if (!strcmp(argv[i], "--version")) + return printVersion(); + else if (!file && strncmp(argv[i], "--", 2)) file = argv[i]; else return printUsage(); diff --git a/src/conv/svg/cmx2xhtml.cpp b/src/conv/svg/cmx2xhtml.cpp index 2c926ec..524bd63 100644 --- a/src/conv/svg/cmx2xhtml.cpp +++ b/src/conv/svg/cmx2xhtml.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <iostream> #include <sstream> #include <stdio.h> @@ -16,6 +20,10 @@ #include <librevenge-stream/librevenge-stream.h> #include <libcdr/libcdr.h> +#ifndef VERSION +#define VERSION "UNKNOWN VERSION" +#endif + namespace { @@ -27,11 +35,18 @@ int printUsage() printf("\n"); printf("Options:\n"); printf("\t--help show this help message\n"); + printf("\t--version show version information and exit\n"); printf("\n"); printf("Report bugs to <https://bugs.documentfoundation.org/>.\n"); return -1; } +int printVersion() +{ + printf("cmx2xhtml " VERSION "\n"); + return 0; +} + } // anonymous namespace int main(int argc, char *argv[]) @@ -43,7 +58,9 @@ int main(int argc, char *argv[]) for (int i = 1; i < argc; i++) { - if (!file && strncmp(argv[i], "--", 2)) + if (!strcmp(argv[i], "--version")) + return printVersion(); + else if (!file && strncmp(argv[i], "--", 2)) file = argv[i]; else return printUsage(); diff --git a/src/conv/text/cdr2text.cpp b/src/conv/text/cdr2text.cpp index dfc2645..f8a5b41 100644 --- a/src/conv/text/cdr2text.cpp +++ b/src/conv/text/cdr2text.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> @@ -15,6 +19,10 @@ #include <librevenge-stream/librevenge-stream.h> #include <libcdr/libcdr.h> +#ifndef VERSION +#define VERSION "UNKNOWN VERSION" +#endif + namespace { @@ -26,11 +34,18 @@ int printUsage() printf("\n"); printf("Options:\n"); printf("\t--help show this help message\n"); + printf("\t--version show version information and exit\n"); printf("\n"); printf("Report bugs to <https://bugs.documentfoundation.org/>.\n"); return -1; } +int printVersion() +{ + printf("cdr2text " VERSION "\n"); + return 0; +} + } // anonymous namespace int main(int argc, char *argv[]) @@ -42,7 +57,9 @@ int main(int argc, char *argv[]) for (int i = 1; i < argc; i++) { - if (!file && strncmp(argv[i], "--", 2)) + if (!strcmp(argv[i], "--version")) + return printVersion(); + else if (!file && strncmp(argv[i], "--", 2)) file = argv[i]; else return printUsage(); diff --git a/src/conv/text/cmx2text.cpp b/src/conv/text/cmx2text.cpp index b734855..1fa595e 100644 --- a/src/conv/text/cmx2text.cpp +++ b/src/conv/text/cmx2text.cpp @@ -7,6 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <stdio.h> #include <string.h> #include <librevenge/librevenge.h> @@ -14,6 +18,10 @@ #include <librevenge-stream/librevenge-stream.h> #include <libcdr/libcdr.h> +#ifndef VERSION +#define VERSION "UNKNOWN VERSION" +#endif + namespace { @@ -25,11 +33,18 @@ int printUsage() printf("\n"); printf("Options:\n"); printf("\t--help show this help message\n"); + printf("\t--version show version information and exit\n"); printf("\n"); printf("Report bugs to <https://bugs.documentfoundation.org/>.\n"); return -1; } +int printVersion() +{ + printf("cmx2text " VERSION "\n"); + return 0; +} + } // anonymous namespace int main(int argc, char *argv[]) @@ -41,7 +56,9 @@ int main(int argc, char *argv[]) for (int i = 1; i < argc; i++) { - if (!file && strncmp(argv[i], "--", 2)) + if (!strcmp(argv[i], "--version")) + return printVersion(); + else if (!file && strncmp(argv[i], "--", 2)) file = argv[i]; else return printUsage(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits