diff -Nru dhcpoptinj-0.5.2/CHANGELOG.md dhcpoptinj-0.5.3/CHANGELOG.md --- dhcpoptinj-0.5.2/CHANGELOG.md 2019-05-09 15:32:30.000000000 +0000 +++ dhcpoptinj-0.5.3/CHANGELOG.md 2019-08-06 14:16:00.000000000 +0000 @@ -6,6 +6,13 @@ ## Unreleased +## 0.5.3 - 2019-08-06 +### Fixed +- Fix two format arguments in debug output printing (fairly pedantic; not even + caught by clang analyser). +- Limit DHCP options to 255 bytes (not 256). +- Exit if a DHCP option is too long. + ## 0.5.2 - 2019-05-09 ### Added - Add example output "screenshot" to README. diff -Nru dhcpoptinj-0.5.2/CMakeLists.txt dhcpoptinj-0.5.3/CMakeLists.txt --- dhcpoptinj-0.5.2/CMakeLists.txt 2019-05-09 15:32:30.000000000 +0000 +++ dhcpoptinj-0.5.3/CMakeLists.txt 2019-08-06 14:16:00.000000000 +0000 @@ -18,7 +18,7 @@ project( ${PROJECT} - VERSION 0.5.2 + VERSION 0.5.3 DESCRIPTION "DHCP option injector" LANGUAGES C ) diff -Nru dhcpoptinj-0.5.2/debian/changelog dhcpoptinj-0.5.3/debian/changelog --- dhcpoptinj-0.5.2/debian/changelog 2019-04-06 22:42:49.000000000 +0000 +++ dhcpoptinj-0.5.3/debian/changelog 2019-08-07 05:24:10.000000000 +0000 @@ -1,3 +1,11 @@ +dhcpoptinj (0.5.3-1) unstable; urgency=medium + + * New upstream version 0.5.3 + * Do not treat compiler warnings as errors + * Use latest Debian policy standards version + + -- Andreas Misje Wed, 07 Aug 2019 07:24:10 +0200 + dhcpoptinj (0.5.2-1) unstable; urgency=medium * Initial release. Closes: #923605 diff -Nru dhcpoptinj-0.5.2/debian/control dhcpoptinj-0.5.3/debian/control --- dhcpoptinj-0.5.2/debian/control 2019-04-06 22:42:49.000000000 +0000 +++ dhcpoptinj-0.5.3/debian/control 2019-08-01 11:04:17.000000000 +0000 @@ -2,7 +2,7 @@ Maintainer: Andreas Misje Section: net Priority: optional -Standards-Version: 4.3.0 +Standards-Version: 4.4.0 Homepage: https://github.com/misje/dhcpoptinj Vcs-Git: https://salsa.debian.org/misje-guest/dhcpoptinj.git Vcs-Browser: https://salsa.debian.org/misje-guest/dhcpoptinj diff -Nru dhcpoptinj-0.5.2/debian/patches/0001-Do-not-treat-compiler-warnings-as-errors.patch dhcpoptinj-0.5.3/debian/patches/0001-Do-not-treat-compiler-warnings-as-errors.patch --- dhcpoptinj-0.5.2/debian/patches/0001-Do-not-treat-compiler-warnings-as-errors.patch 1970-01-01 00:00:00.000000000 +0000 +++ dhcpoptinj-0.5.3/debian/patches/0001-Do-not-treat-compiler-warnings-as-errors.patch 2019-08-01 09:04:50.000000000 +0000 @@ -0,0 +1,23 @@ +From: Andreas Misje +Date: Thu, 1 Aug 2019 10:57:42 +0200 +Subject: Do not treat compiler warnings as errors + +This should allow for successful builds on the obscure non-supported +architectures, whose compilers do not have features like stack +protector. +--- + CMakeLists.txt | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4770252..90538bd 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -57,7 +57,6 @@ target_compile_options(${PROJECT} PRIVATE + -Wno-error=strict-overflow + -Wswitch-default + -Wundef +- -Werror + -Wno-unused + -Wmissing-prototypes + -Wstrict-prototypes diff -Nru dhcpoptinj-0.5.2/debian/patches/series dhcpoptinj-0.5.3/debian/patches/series --- dhcpoptinj-0.5.2/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ dhcpoptinj-0.5.3/debian/patches/series 2019-08-01 09:04:50.000000000 +0000 @@ -0,0 +1 @@ +0001-Do-not-treat-compiler-warnings-as-errors.patch diff -Nru dhcpoptinj-0.5.2/README.md dhcpoptinj-0.5.3/README.md --- dhcpoptinj-0.5.2/README.md 2019-05-09 15:32:30.000000000 +0000 +++ dhcpoptinj-0.5.3/README.md 2019-08-06 14:16:00.000000000 +0000 @@ -1,4 +1,5 @@ # DHCP option injector +[![Build Status](https://travis-ci.org/misje/dhcpoptinj.svg?branch=dev)](https://travis-ci.org/misje/dhcpoptinj) [![Total alerts](https://img.shields.io/lgtm/alerts/g/misje/dhcpoptinj.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/misje/dhcpoptinj/alerts/) Have you ever wanted to intercept DHCP requests and squeeze in a few extra DHCP options, unbeknownst to the sender? Probably not. However, should the need ever @@ -104,13 +105,13 @@ ``` ## Installing +[![Packaging status](https://repology.org/badge/vertical-allrepos/dhcpoptinj.svg)](https://repology.org/project/dhcpoptinj/versions) -dhcpoptinj is submitted to Debian and will hopefully make it to unstable (and -consequently testing and stable) in not too long. The deb package is under -source control at [salsa](https://salsa.debian.org/misje-guest/dhcpoptinj). -Installing dhcpoptinj from the deb package is recommended over the following -manual installation procedure, because it also includes a man page, bash -completion rules, example files etc. +dhcpoptinj is in Debian/Ubuntu. The deb package is under source control at +[salsa](https://salsa.debian.org/misje-guest/dhcpoptinj). Installing +dhcpoptinj from the deb package is recommended over the following manual +installation procedure, because it also includes a man page, bash completion +rules, example files etc. ### Prerequisites diff -Nru dhcpoptinj-0.5.2/src/config.c dhcpoptinj-0.5.3/src/config.c --- dhcpoptinj-0.5.2/src/config.c 2019-05-09 15:32:30.000000000 +0000 +++ dhcpoptinj-0.5.3/src/config.c 2019-08-06 14:16:00.000000000 +0000 @@ -317,7 +317,7 @@ "The option hex string is written as a series of two-digit pairs,\n" "optionally delimited by one or more non-hexadecimal characters:\n" "'466A6173','46 6A 61 73', '46:6A:61:73' etc. There is a maximum limit\n" - "of 256 bytes per option, excluding the option code (the first byte)\n" + "of 255 bytes per option, excluding the option code (the first byte)\n" "and the automatically inserted length byte. At least one option must\n" "be provided.\n" "\n" @@ -371,8 +371,8 @@ if (!string) return; - /* Make room for length byte and payload */ - uint8_t buffer[1 + 256]; + /* Make room for option code byte and payload */ + uint8_t buffer[1 + UINT8_MAX]; size_t length = 0; for (size_t i = 0; i < strlen(string) && length < sizeof(buffer);) { @@ -384,8 +384,15 @@ else ++i; } + /* Will not happen; the cmd.line parsing code expects an argument: */ if (!length) return; + if (length > UINT8_MAX) + { + fprintf(stderr, "DHCP option size exceeds the limit of %u bytes\n", + UINT8_MAX); + exit(EXIT_FAILURE); + } uint16_t optCode = buffer[0]; @@ -522,6 +529,7 @@ fputs("Could not allocate space for PID file name\n", stderr); exit(EXIT_FAILURE); } + // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.strcpy) strcpy(config->pidFile, src); } break; diff -Nru dhcpoptinj-0.5.2/src/dhcpoptinj.c dhcpoptinj-0.5.3/src/dhcpoptinj.c --- dhcpoptinj-0.5.2/src/dhcpoptinj.c 2019-05-09 15:32:30.000000000 +0000 +++ dhcpoptinj-0.5.3/src/dhcpoptinj.c 2019-08-06 14:16:00.000000000 +0000 @@ -500,6 +500,7 @@ if (priority == LOG_NOTICE || priority == LOG_INFO || priority == LOG_DEBUG) f = stdout; + /* NOLINTNEXTLINE(clang-analyzer-valist.Uninitialized) */ vfprintf(f, format, args1); } va_end(args1); @@ -586,7 +587,7 @@ if (!config->debug) return; - logMessage(LOG_DEBUG, "%u DHCP option(s) to inject (with a total of %zu bytes): ", + logMessage(LOG_DEBUG, "%zu DHCP option(s) to inject (with a total of %zu bytes): ", config->dhcpOptCodeCount, config->dhcpOptsSize); for (size_t i = 0; i < config->dhcpOptCodeCount; ++i) @@ -654,9 +655,9 @@ static void debugLogOption(const char *action, const struct DHCPOption *option) { - /* String buffer for hex string (maximum DHCP option length (256) times + /* String buffer for hex string (maximum DHCP option length (255) times * three characters (two digits and a space)) */ - char optPayload[256 * 3]; + char optPayload[UINT8_MAX * 3]; size_t i = 0; for (; i < option->length; ++i) sprintf(optPayload + 3*i, "%02X ", option->data[i]); @@ -673,7 +674,7 @@ option->code, option->code, optName, - optNameLen > alignedWidth ? 0 : alignedWidth - optNameLen, + (int)(optNameLen > alignedWidth ? 0 : alignedWidth - optNameLen), "", option->length, optPayload); diff -Nru dhcpoptinj-0.5.2/src/options.c dhcpoptinj-0.5.3/src/options.c --- dhcpoptinj-0.5.2/src/options.c 2019-05-09 15:32:30.000000000 +0000 +++ dhcpoptinj-0.5.3/src/options.c 2019-08-06 14:16:00.000000000 +0000 @@ -28,7 +28,7 @@ { uint8_t code; uint8_t length; - uint8_t data[256]; + uint8_t data[UINT8_MAX]; }; struct DHCPOptList diff -Nru dhcpoptinj-0.5.2/.travis.yml dhcpoptinj-0.5.3/.travis.yml --- dhcpoptinj-0.5.2/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ dhcpoptinj-0.5.3/.travis.yml 2019-08-06 14:16:00.000000000 +0000 @@ -0,0 +1,16 @@ +addons: + apt: + update: true + packages: + - libnetfilter-queue-dev +dist: xenial +language: c +compiler: + - clang + - gcc +before_script: + - mkdir build +script: + - cd build + - cmake .. + - make -j2