Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package nanopb for openSUSE:Factory checked in at 2026-11-13 18:31:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nanopb (Old) and /work/SRC/openSUSE:Factory/.nanopb.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nanopb" Fri Nov 13 18:31:21 2026 rev:16 rq:1397016 version:0.4.9.3 Changes: -------- --- /work/SRC/openSUSE:Factory/nanopb/nanopb.changes 2026-09-01 15:52:14.866901573 +0200 +++ /work/SRC/openSUSE:Factory/.nanopb.new.1251/nanopb.changes 2026-11-13 18:35:08.475816941 +0100 @@ -1,0 +2,22 @@ +Thu Nov 12 07:11:35 UTC 2026 - Paolo Stivanin <[email protected]> + +- Update to 0.4.9.3: + * Fix out-of-bounds release of pointer fixed count arrays + (GHSA-5v96-h584-4px4) + * Fix invalid free with repeated submessages (GHSA-5v96-h584-4px4) + * Fix invalid free of static fixed count submessage arrays (#1217) + * Fix callback inside oneof calling unsafe function ptr + (GHSA-fmpg-qc28-5x4x) + * Fix regression with filename patterns in .options files (#1195) + * Fixes for custom extension types (#1210, #1209) + * Fix float default initializers in exponent form (#1207) + * Fix C escaping of string default initializers (#1193) + * Reject submsg_callback on fixed_count fields (#1212) + * Fix macOS package architecture labels (#1205) + * Fix AttributeError CodeGeneratorResponse with some python-protobuf + versions (#1189) + * Update Python version in Linux binary packages (#1218) + * Preserve NaN values in double-to-float decoding (#1185) + * CMake build fixes + +------------------------------------------------------------------- Old: ---- nanopb-0.4.9.2.tar.gz New: ---- nanopb-0.4.9.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nanopb.spec ++++++ --- /var/tmp/diff_new_pack.C6Kclz/_old 2026-11-13 18:35:09.893876978 +0100 +++ /var/tmp/diff_new_pack.C6Kclz/_new 2026-11-13 18:35:09.894877020 +0100 @@ -19,7 +19,7 @@ %define sover 0 %define src_install_dir %{_prefix}/src/%{name} Name: nanopb -Version: 0.4.9.2 +Version: 0.4.9.3 Release: 0 Summary: Protocol Buffers with small code size License: Zlib ++++++ nanopb-0.4.9.2.tar.gz -> nanopb-0.4.9.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/.github/workflows/bazel.yml new/nanopb-0.4.9.3/.github/workflows/bazel.yml --- old/nanopb-0.4.9.2/.github/workflows/bazel.yml 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/.github/workflows/bazel.yml 2026-11-11 12:49:17.000000000 +0100 @@ -25,7 +25,7 @@ uses: actions/cache@v6 with: path: "/home/runner/.cache/bazel" - key: ${{ runner.os }}-bazel + key: ${{ runner.os }}-bazel-${{ matrix.bazel }}-bump20261106 - name: Test run: | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/.github/workflows/binary_packages.yml new/nanopb-0.4.9.3/.github/workflows/binary_packages.yml --- old/nanopb-0.4.9.2/.github/workflows/binary_packages.yml 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/.github/workflows/binary_packages.yml 2026-11-11 12:49:17.000000000 +0100 @@ -24,7 +24,7 @@ - name: Setup Python uses: actions/setup-python@v6 with: - python-version: '3.8' + python-version: '3.13' - name: Install dependencies run: | @@ -68,6 +68,7 @@ (cd cmake_with_components; mkdir build; cd build; cmake ..; make) (cd legacy_cmake_relpath; mkdir build; cd build; cmake ..; make) (cd legacy_cmake_simple; mkdir build; cd build; cmake ..; make) + (cd legacy_cmake_generated_sources; mkdir build; cd build; cmake ..; make) build_windows: name: Build binary on Windows 2022 @@ -112,8 +113,16 @@ python3 -m SCons build_macos: - name: Build binary on Mac OS X 14 - runs-on: macos-14 + name: Build binary on macOS 15 (${{ matrix.architecture }}) + strategy: + fail-fast: false + matrix: + include: + - runner: macos-15 + architecture: arm64 + - runner: macos-15-intel + architecture: x86_64 + runs-on: ${{ matrix.runner }} steps: - name: Check out code from GitHub @@ -139,11 +148,17 @@ run: | openssl sha256 nanopb/dist/*.tar.gz + - name: Verify binary architecture + run: | + test "$(uname -m)" = "${{ matrix.architecture }}" + test "$(lipo -archs nanopb/dist/*/generator-bin/nanopb_generator)" = "${{ matrix.architecture }}" + test "$(lipo -archs nanopb/dist/*/generator-bin/protoc)" = "${{ matrix.architecture }}" + - name: Upload binary uses: actions/upload-artifact@v7 with: path: nanopb/dist/*.tar.gz - name: nanopb-binary-macos + name: nanopb-binary-macos-${{ matrix.architecture }} - name: Test binary package run: | diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/.github/workflows/compiler_tests.yml new/nanopb-0.4.9.3/.github/workflows/compiler_tests.yml --- old/nanopb-0.4.9.2/.github/workflows/compiler_tests.yml 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/.github/workflows/compiler_tests.yml 2026-11-11 12:49:17.000000000 +0100 @@ -22,7 +22,7 @@ sudo apt-get update sudo apt-get install python3-protobuf protobuf-compiler scons sudo apt-get install clang valgrind splint cmake - sudo apt-get install libstdc++6:i386 libgcc-s1:i386 lib32gcc-13-dev lib32stdc++-13-dev libc6-dbg:i386 libc6-dev:i386 binutils-multiarch + sudo apt-get install libstdc++6:i386 libgcc-s1:i386 libc6-dbg:i386 libc6-dev:i386 gcc-multilib g++-multilib binutils-multiarch - name: Test with 64-bit GCC run: | @@ -38,11 +38,13 @@ run: | cd nanopb/tests rm -rf build - scons CC=gcc CXX=g++ CCFLAGS="-O3 -m32" LINKFLAGS="-m32" + # Disable valgrind because for some reason modern GCC multilib uses AVX instructions + # on 64-bit platforms even for 32-bit binaries, which makes valgrind crash with "Illegal opcode" + scons CC=gcc CXX=g++ CCFLAGS="-O3 -m32" LINKFLAGS="-m32" NOVALGRIND=1 rm -rf build - scons CC=gcc CXX=g++ CCFLAGS="-Os -flto -m32" LINKFLAGS="-m32" + scons CC=gcc CXX=g++ CCFLAGS="-Os -flto -m32" LINKFLAGS="-m32" NOVALGRIND=1 rm -rf build - scons CC=gcc CXX=g++ CCFLAGS="-O1 -DPB_FIELD_32BIT=1 -m32" LINKFLAGS="-m32" + scons CC=gcc CXX=g++ CCFLAGS="-O1 -DPB_FIELD_32BIT=1 -m32" LINKFLAGS="-m32" NOVALGRIND=1 - name: Test with 64-bit clang run: | @@ -56,7 +58,7 @@ run: | cd nanopb/tests rm -rf build - scons CC=clang CXX=clang++ CCFLAGS="-O3 -m32" LINKFLAGS="-m32" + scons CC=clang CXX=clang++ CCFLAGS="-O3 -m32" LINKFLAGS="-m32" NOVALGRIND=1 rm -rf build - scons CC=clang CXX=clang++ CCFLAGS="-Os -DPB_FIELD_32BIT=1 -m32" LINKFLAGS="-m32" + scons CC=clang CXX=clang++ CCFLAGS="-Os -DPB_FIELD_32BIT=1 -m32" LINKFLAGS="-m32" NOVALGRIND=1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/.github/workflows/trigger_on_schedule.yml new/nanopb-0.4.9.3/.github/workflows/trigger_on_schedule.yml --- old/nanopb-0.4.9.2/.github/workflows/trigger_on_schedule.yml 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/.github/workflows/trigger_on_schedule.yml 2026-11-11 12:49:17.000000000 +0100 @@ -11,9 +11,6 @@ simulator_tests: uses: ./.github/workflows/simulator_tests.yml - python2_tests: - uses: ./.github/workflows/python2_tests.yml - ios_swift_tests: uses: ./.github/workflows/ios_swift_tests.yml @@ -27,7 +24,7 @@ uses: ./.github/workflows/cifuzz.yml binary_packages: - needs: [compiler_tests, simulator_tests, python2_tests, ios_swift_tests, platformio_tests, cifuzz] + needs: [compiler_tests, simulator_tests, ios_swift_tests, platformio_tests, cifuzz] uses: ./.github/workflows/binary_packages.yml pypi_publish: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/AUTHORS.txt new/nanopb-0.4.9.3/AUTHORS.txt --- old/nanopb-0.4.9.2/AUTHORS.txt 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/AUTHORS.txt 2026-11-11 12:49:17.000000000 +0100 @@ -165,3 +165,14 @@ Red Daly <[email protected]> Şan Güneş <[email protected]> weichslgartner <[email protected]> +APX403 <[email protected]> +Braian PLAKU <[email protected]> +fhgffy <[email protected]> +Firat Hajiyev <[email protected]> +Keshava P <[email protected]> +Michele Dionisio <[email protected]> +Rupayon Haldar <[email protected]> +skr <[email protected]> +trestoncuzzort <[email protected]> +vpfkfl753 <[email protected]> +zhangyuyang <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/CHANGELOG.txt new/nanopb-0.4.9.3/CHANGELOG.txt --- old/nanopb-0.4.9.2/CHANGELOG.txt 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/CHANGELOG.txt 2026-11-11 12:49:17.000000000 +0100 @@ -1,3 +1,19 @@ +nanopb-0.4.9.3 (2026-11-11) + Fix out-of-bounds release of pointer fixed count arrays (GHSA-5v96-h584-4px4) + Fix invalid free with repeated submessages (GHSA-5v96-h584-4px4) + Fix invalid free of static fixed count submessage arrays (#1217) + Fix callback inside oneof calling unsafe function ptr (GHSA-fmpg-qc28-5x4x) + Fix regression with filename patterns in .options files (#1195) + Fixes for custom extension types (#1210, #1209) + Fix float default initializers in exponent form (#1207) + Fix C escaping of string default initializers (#1193) + Reject submsg_callback on fixed_count fields (#1212) + Fix macOS package architecture labels (#1205) + Fix AttributeError CodeGeneratorResponse with some python-protobuf versions (#1189) + Update Python version in Linux binary packages (#1218) + Preserve NaN values in double-to-float decoding (#1185) + CMake build fixes + nanopb-0.4.9.2 (2026-08-24) Fix callback and oneof calling attacker-controlled ptr (GHSA-p24j-vqcp-x988) Fix callback for message inside oneof not getting called (#1061) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/CMakeLists.txt new/nanopb-0.4.9.3/CMakeLists.txt --- old/nanopb-0.4.9.2/CMakeLists.txt 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/CMakeLists.txt 2026-11-11 12:49:17.000000000 +0100 @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14.0) -project(nanopb VERSION 0.4.9.2 LANGUAGES C) +project(nanopb VERSION 0.4.9.3 LANGUAGES C) set(nanopb_VERSION_STRING ${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}-dev) set(nanopb_SOVERSION 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/MODULE.bazel new/nanopb-0.4.9.3/MODULE.bazel --- old/nanopb-0.4.9.2/MODULE.bazel 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/MODULE.bazel 2026-11-11 12:49:17.000000000 +0100 @@ -1,6 +1,6 @@ module( name = "nanopb", - version = "0.4.9.2", + version = "0.4.9.3", ) bazel_dep(name = "bazel_skylib", version = "1.7.1") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/build-tests/legacy_cmake_generated_sources/CMakeLists.txt new/nanopb-0.4.9.3/build-tests/legacy_cmake_generated_sources/CMakeLists.txt --- old/nanopb-0.4.9.2/build-tests/legacy_cmake_generated_sources/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/build-tests/legacy_cmake_generated_sources/CMakeLists.txt 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.5) +project(NANOPB_CMAKE_GENERATED_SOURCES C) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra) +find_package(Nanopb REQUIRED) +include_directories(${NANOPB_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) + +# Regression for #1104: reusing the output variables must not mark runtime +# sources as generated, because the clean target would then delete them. +set(NANOPB_RUNTIME_FILES ${NANOPB_SRCS} ${NANOPB_HDRS}) +nanopb_generate_cpp(NANOPB_SRCS NANOPB_HDRS ../legacy_cmake_simple/simple.proto) +foreach(source_file ${NANOPB_RUNTIME_FILES}) + get_source_file_property(is_generated ${source_file} GENERATED) + if(is_generated) + message(FATAL_ERROR "Runtime source marked as generated: ${source_file}") + endif() +endforeach() + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0") +add_executable(simple ../legacy_cmake_simple/simple.c ${NANOPB_SRCS} ${NANOPB_HDRS}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/conanfile.py new/nanopb-0.4.9.3/conanfile.py --- old/nanopb-0.4.9.2/conanfile.py 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/conanfile.py 2026-11-11 12:49:17.000000000 +0100 @@ -3,7 +3,7 @@ class NanoPbConan(ConanFile): name = "nanopb" - version = "0.4.9.2" + version = "0.4.9.3" license = "zlib" url = "https://jpa.kapsi.fi/nanopb/" description = "Protocol Buffers with small code size" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/docs/concepts.md new/nanopb-0.4.9.3/docs/concepts.md --- old/nanopb-0.4.9.2/docs/concepts.md 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/docs/concepts.md 2026-11-11 12:49:17.000000000 +0100 @@ -448,9 +448,22 @@ tag: MyMessage msg = MyMessage_init_zero; + memset(&msg.payload, 0, sizeof(msg.payload)); msg.payload.msg2.value = true; msg.which_payload = MyMessage_msg2_tag; +Include `<string.h>` for `memset()`. For an automatic (non-static) variable, +GCC 15 and later no longer guarantee that the `{0}` initializer used by +`MyMessage_init_zero` clears the whole `oneof` union; it initializes only the +first union member. Clearing the union before selecting a member prevents +unassigned fields in a larger member from retaining indeterminate data. Do +the same when reusing a message and switching to a different `oneof` member. +See the [GCC 15 release notes](https://gcc.gnu.org/gcc-15/changes.html) for +the compiler change. Do not replace `MyMessage_init_zero` with a whole-message +`memset()`, because generated initializers may set nonzero field defaults. +After clearing the union, set any defaults required by the selected message +before assigning its other fields. + Notice that neither `which_payload` field nor the unused fields in `payload` will consume any space in the resulting encoded message. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/docs/migration.md new/nanopb-0.4.9.3/docs/migration.md --- old/nanopb-0.4.9.2/docs/migration.md 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/docs/migration.md 2026-11-11 12:49:17.000000000 +0100 @@ -6,6 +6,22 @@ error indications are included, in order to make it easier to find this document. +Nanopb-0.4.9.3 (2026-11-11) +--------------------------- + +### Callbacks directly inside oneofs are disabled by default + +**Rationale:** Previously there was a special feature for supporting +callback-type fields directly inside oneofs. This turned out to be a poor +design, with inherent security problems when untrusted data is decoded. +See [GHSA-fmpg-qc28-5x4x](https://github.com/nanopb/nanopb/security/advisories/GHSA-fmpg-qc28-5x4x) for details. + +**Changes:** Callbacks directly inside oneofs are now disabled by default. +There is a compile-time setting `PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS` which can be used for legacy code if the input data is trusted. + +**Required actions:** For untrusted data, it is recommended to use one of the `submsg_callback`, `no_unions` or `callback_function` generator options instead. See `tests/oneof_callback` for examples. + + Nanopb-0.4.9 (2024-09-19) ------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/extra/FindNanopb.cmake new/nanopb-0.4.9.3/extra/FindNanopb.cmake --- old/nanopb-0.4.9.2/extra/FindNanopb.cmake 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/extra/FindNanopb.cmake 2026-11-11 12:49:17.000000000 +0100 @@ -327,8 +327,6 @@ endforeach() - set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) - if(NANOPB_GENERATE_CPP_TARGET) add_library(${NANOPB_GENERATE_CPP_TARGET} STATIC EXCLUDE_FROM_ALL ${${SRCS}} ${${HDRS}}) target_include_directories(${NANOPB_GENERATE_CPP_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/extra/poetry/pyproject.toml new/nanopb-0.4.9.3/extra/poetry/pyproject.toml --- old/nanopb-0.4.9.2/extra/poetry/pyproject.toml 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/extra/poetry/pyproject.toml 2026-11-11 12:49:17.000000000 +0100 @@ -1,6 +1,6 @@ [tool.poetry] name = "nanopb" -version = "0.4.9.2" +version = "0.4.9.3" description = "Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system." authors = ["Petteri Aimonen <[email protected]>"] license = "Zlib" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/generator/nanopb_generator.py new/nanopb-0.4.9.3/generator/nanopb_generator.py --- old/nanopb-0.4.9.2/generator/nanopb_generator.py 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/generator/nanopb_generator.py 2026-11-11 12:49:17.000000000 +0100 @@ -4,7 +4,7 @@ from __future__ import unicode_literals '''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.''' -nanopb_version = "nanopb-0.4.9.2" +nanopb_version = "nanopb-0.4.9.3" import sys import re @@ -26,6 +26,7 @@ try: import google.protobuf.text_format as text_format + import google.protobuf.text_encoding as text_encoding import google.protobuf.descriptor_pb2 as descriptor import google.protobuf.compiler.plugin_pb2 as plugin_pb2 import google.protobuf.descriptor @@ -762,6 +763,15 @@ # Add submessage callback for statically allocated fields inside or # outside oneofs. This can be used for repeated fields and oneofs. if field_options.submsg_callback and self.allocation == 'STATIC': + # The callback is stored in a pb_callback_t placed in front of + # the field's _count (repeated) or which_ (oneof) member. Fixed + # count arrays have neither, so pSize points at the iterator's + # array_size instead and pb_dec_submessage()/pb_enc_submessage() + # would read the callback out of bounds. + if self.rules == 'FIXARRAY': + raise Exception("Field '%s' sets both fixed_count and submsg_callback, " + "but submsg_callback is not supported for fixed count " + "arrays." % self.name) self.pbtype = 'MSG_W_CB' else: raise NotImplementedError(desc.type) @@ -866,8 +876,9 @@ inner_init = '0' else: if self.pbtype == 'STRING': - data = codecs.escape_encode(self.default.encode('utf-8'))[0] - inner_init = '"' + data.decode('ascii') + '"' + data = text_encoding.CEscape(self.default.encode('utf-8'), False) + # Escape question marks to prevent C trigraph conversion. + inner_init = '"' + data.replace('?', r'\?') + '"' elif self.pbtype == 'BYTES': data = codecs.escape_decode(self.default)[0] data = ["0x%02x" % c for c in bytearray(data)] @@ -894,7 +905,7 @@ inner_init = inner_init.replace('inf', 'INFINITY') elif 'nan' in inner_init: inner_init = inner_init.replace('nan', 'NAN') - elif (not '.' in inner_init) and self.pbtype == 'FLOAT': + elif (not '.' in inner_init) and (not 'e' in inner_init) and self.pbtype == 'FLOAT': inner_init += '.0f' elif self.pbtype == 'FLOAT': inner_init += 'f' @@ -2361,7 +2372,7 @@ if '/' in namemask or namemask.endswith('.proto'): invalid = re.search(r'[\s:]', namemask) else: - invalid = re.search(r'[^A-Za-z0-9_.*?\[\]!]', namemask) + invalid = re.search(r'[^A-Za-z0-9_.*?\[\]!-]', namemask) if invalid: hint = "" if invalid.group(0) == ':': @@ -2376,7 +2387,7 @@ '''Remove comments from .options data without touching quoted strings.''' string_or_comment = re.compile( r'''(?P<string>"(?:\\.|[^"\\\r\n])*(?:"|$)|'(?:\\.|[^'\\\r\n])*(?:'|$))''' - r'''|(?P<comment>/\*.*?(?:\*/|\Z)|//[^\r\n]*|#[^\r\n]*)''', + r'''|(?P<comment>(?:^|(?<=\s))/\*.*?(?:\*/|\Z)|/\*[^\r\n]*?\*/|//[^\r\n]*|#[^\r\n]*)''', flags = re.MULTILINE | re.DOTALL) def strip_comment(match): @@ -2805,7 +2816,11 @@ if hasattr(plugin_pb2.CodeGeneratorResponse, "FEATURE_PROTO3_OPTIONAL"): response.supported_features = plugin_pb2.CodeGeneratorResponse.FEATURE_PROTO3_OPTIONAL - if hasattr(plugin_pb2.CodeGeneratorResponse, "FEATURE_SUPPORTS_EDITIONS"): + if (hasattr(plugin_pb2.CodeGeneratorResponse, "FEATURE_SUPPORTS_EDITIONS") + and hasattr(response, "minimum_edition")): + # Some protobuf versions expose the FEATURE_SUPPORTS_EDITIONS enum value on + # CodeGeneratorResponse before also adding the minimum_edition/maximum_edition + # fields to the same message, so the two have to be checked independently. response.supported_features |= plugin_pb2.CodeGeneratorResponse.FEATURE_SUPPORTS_EDITIONS response.minimum_edition = descriptor.EDITION_PROTO2 response.maximum_edition = descriptor.EDITION_2024 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/library.json new/nanopb-0.4.9.3/library.json --- old/nanopb-0.4.9.2/library.json 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/library.json 2026-11-11 12:49:17.000000000 +0100 @@ -1,6 +1,6 @@ { "name": "Nanopb", - "version": "0.4.92", + "version": "0.4.93", "keywords": "protocol buffers, protobuf, google", "description": "Nanopb is a plain-C implementation of Google's Protocol Buffers data format. It is targeted at 32 bit microcontrollers, but is also fit for other embedded systems with tight (<10 kB ROM, <1 kB RAM) memory constraints.", "repository": { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/pb.h new/nanopb-0.4.9.3/pb.h --- old/nanopb-0.4.9.2/pb.h 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/pb.h 2026-11-11 12:49:17.000000000 +0100 @@ -60,6 +60,13 @@ /* Limit for depth of recursive message structure */ /* #define PB_MESSAGE_NESTING_MAX 10 */ +/* Enable support for legacy callbacks inside oneofs when decoding. + * Depending on message structure, this may be unsafe if decoded data + * is untrusted. This is disabled by default since nanopb-0.4.9.3. + * Prefer using submsg_callback, no_unions or callback_function generator + * options instead. See GHSA-p24j-vqcp-x988 for details. */ +/* #define PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS 1 */ + /****************************************************************** * You usually don't need to change anything below this line. * * Feel free to look around and use the defined macros, though. * @@ -68,7 +75,7 @@ /* Version of the nanopb library. Just in case you want to check it in * your own program. */ -#define NANOPB_VERSION "nanopb-0.4.9.2" +#define NANOPB_VERSION "nanopb-0.4.9.3" /* Include all the system headers needed by nanopb. You will need the * definitions of the following: @@ -381,7 +388,14 @@ * Note that actual structs used will have a different length of bytes array. */ #define PB_BYTES_ARRAY_T(n) struct { pb_size_t size; pb_byte_t bytes[n]; } -#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes)) +/* Size to allocate for a bytes array holding n bytes. Never less than the + * struct itself, so a pb_bytes_array_t pointer into the allocation stays + * inside it for small n (gcc -Warray-bounds complains otherwise). + */ +#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) \ + (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \ + ? sizeof(pb_bytes_array_t) \ + : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes))) struct pb_bytes_array_s { pb_size_t size; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/pb_decode.c new/nanopb-0.4.9.3/pb_decode.c --- old/nanopb-0.4.9.2/pb_decode.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/pb_decode.c 2026-11-11 12:49:17.000000000 +0100 @@ -525,6 +525,19 @@ if ((*size)++ >= field->array_size) PB_RETURN_ERROR(stream, "array overflow"); + if (PB_LTYPE_IS_SUBMSG(field->type)) + { + /* The entry is now counted, so pb_release() will walk it + * even if decoding fails before pb_dec_submessage(). + * Set defaults here so that its pointers are valid. */ + pb_field_iter_t submsg_iter; + if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData)) + { + if (!pb_message_set_to_defaults(&submsg_iter)) + PB_RETURN_ERROR(stream, "failed to set defaults"); + } + } + return decode_basic_field(stream, wire_type, field); } @@ -743,7 +756,27 @@ if (*size == PB_SIZE_MAX) PB_RETURN_ERROR(stream, "too many array entries"); - if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1))) + if (field->array_size > 1) + { + /* Fixed count array (array_size is 1 for other pointer arrays). + * There is no count field, so pb_release() frees all array_size + * entries. Allocate and initialize the whole array at once. */ + bool new_array = (*(void**)field->pField == NULL); + + if (*size >= field->array_size) + PB_RETURN_ERROR(stream, "array overflow"); + + if (!allocate_field(stream, field->pField, field->data_size, field->array_size)) + return false; + + if (new_array) + { + pb_size_t i; + for (i = 0; i < field->array_size; i++) + initialize_pointer_field(*(char**)field->pField + field->data_size * i, field); + } + } + else if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1))) return false; field->pData = *(char**)field->pField + field->data_size * (*size); @@ -765,7 +798,13 @@ */ if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF) { - if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag) + bool clear_data = (*(pb_size_t*)field->pSize != field->tag); + +#ifdef PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS + if (*(pb_size_t*)field->pSize == 0) clear_data = false; +#endif + + if (clear_data) { memset(field->pData, 0, (size_t)field->data_size); } @@ -914,7 +953,9 @@ while (ext != NULL) { pb_field_iter_t ext_iter; - if (pb_field_iter_begin_extension(&ext_iter, ext)) + if (ext->type->decode != NULL) + ext->found = false; /* Custom type: arg is not a message descriptor */ + else if (pb_field_iter_begin_extension(&ext_iter, ext)) { ext->found = false; if (!pb_message_set_to_defaults(&ext_iter)) @@ -932,6 +973,26 @@ * itself also. */ *(bool*)field->pSize = false; } + else if (PB_HTYPE(type) == PB_HTYPE_REPEATED && + field->pSize == &field->array_size && + PB_LTYPE_IS_SUBMSG(type)) + { + /* Fixed count array: there is no count field, so pb_release() + * walks all array_size entries even if they were not decoded. + * Initialize all submessages so that their pointers are valid. */ + pb_size_t i; + for (i = 0; i < field->array_size; i++) + { + pb_field_iter_t submsg_iter; + if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, + (char*)field->pData + field->data_size * i)) + { + if (!pb_message_set_to_defaults(&submsg_iter)) + return false; + } + } + init_data = false; + } else if (PB_HTYPE(type) == PB_HTYPE_REPEATED || PB_HTYPE(type) == PB_HTYPE_ONEOF) { @@ -1284,7 +1345,8 @@ while (ext != NULL) { pb_field_iter_t ext_iter; - if (pb_field_iter_begin_extension(&ext_iter, ext)) + if (ext->type->decode == NULL && + pb_field_iter_begin_extension(&ext_iter, ext)) { pb_release_single_field(&ext_iter); } @@ -1335,6 +1397,11 @@ /* Release entries in repeated string or bytes array */ void **pItem = *(void***)field->pField; pb_size_t count = *(pb_size_t*)field->pSize; + + /* Fixed count arrays report array_size even if never allocated */ + if (pItem == NULL) + count = 0; + for (; count > 0; count--) { pb_free(*pItem); @@ -1657,9 +1724,9 @@ unsigned int flags = 0; /* Static required/optional fields are already initialized by top-level - * pb_decode(), no need to initialize them again. */ - if (PB_ATYPE(field->type) == PB_ATYPE_STATIC && - PB_HTYPE(field->type) != PB_HTYPE_REPEATED) + * pb_decode() and repeated/oneof fields by decode_static_field(), no + * need to initialize them again. */ + if (PB_ATYPE(field->type) == PB_ATYPE_STATIC) { flags = PB_DECODE_NOINIT; } @@ -1719,6 +1786,9 @@ /* Special value */ exponent = 128; mantissa >>= 1; + /* Preserve NaN if its payload was lost when narrowing the mantissa. */ + if (mantissa == 0 && (uint32_t)value != 0) + mantissa = 1; } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/SConstruct new/nanopb-0.4.9.3/tests/SConstruct --- old/nanopb-0.4.9.2/tests/SConstruct 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/SConstruct 2026-11-11 12:49:17.000000000 +0100 @@ -14,8 +14,10 @@ LINKLIBS Flags to pass to linker after object files PROTOC Path to protoc binary PROTOCFLAGS Arguments to pass protoc +PLATFORM Run using simulator NODEFARGS Do not add the default CCFLAGS NOVALGRIND Do not use valgrind for memory checks +NOUNSAFE Skip tests that intentionally break memory safety For example, for a clang build, use: scons CC=clang CXX=clang++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/alltypes/decode_alltypes.c new/nanopb-0.4.9.3/tests/alltypes/decode_alltypes.c --- old/nanopb-0.4.9.2/tests/alltypes/decode_alltypes.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/alltypes/decode_alltypes.c 2026-11-11 12:49:17.000000000 +0100 @@ -302,9 +302,6 @@ return status == 0; } -#ifdef __cplusplus -extern "C" -#endif int main(int argc, char **argv) { uint8_t buffer[1024]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/alltypes/encode_alltypes.c new/nanopb-0.4.9.3/tests/alltypes/encode_alltypes.c --- old/nanopb-0.4.9.2/tests/alltypes/encode_alltypes.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/alltypes/encode_alltypes.c 2026-11-11 12:49:17.000000000 +0100 @@ -8,9 +8,6 @@ #include "alltypes.pb.h" #include "test_helpers.h" -#ifdef __cplusplus -extern "C" -#endif int main(int argc, char **argv) { int mode = (argc > 1) ? atoi(argv[1]) : 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/custom_extension/SConscript new/nanopb-0.4.9.3/tests/custom_extension/SConscript --- old/nanopb-0.4.9.2/tests/custom_extension/SConscript 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/custom_extension/SConscript 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,19 @@ +# Test decoding of messages with custom and default extension types. +# Hand-written descriptors, no protoc generation needed. + +Import("env", "malloc_env") + +# Custom extension type (issue #1200) and default extension regression. +test = env.Program("custom_extension", ["custom_extension.c", + "$COMMON/pb_decode.o", + "$COMMON/pb_common.o"]) +env.RunTest(test) + +# Same test with PB_ENABLE_MALLOC, which also exercises pb_release() over the +# extension lists. +malloc_obj = malloc_env.Object("custom_extension_malloc.o", "custom_extension.c") +malloc_test = malloc_env.Program("custom_extension_malloc", [malloc_obj, + "$COMMON/pb_decode_with_malloc.o", + "$COMMON/pb_common_with_malloc.o", + "$COMMON/malloc_wrappers.o"]) +env.RunTest(malloc_test) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/custom_extension/custom_extension.c new/nanopb-0.4.9.3/tests/custom_extension/custom_extension.c --- old/nanopb-0.4.9.2/tests/custom_extension/custom_extension.c 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/custom_extension/custom_extension.c 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,139 @@ +/* Regression test for issue #1200: decoding a message that carries a custom + * pb_extension_type_t (with its own decode/encode callbacks) used to crash in + * pb_field_iter_begin_extension(), because pb_field_set_to_default() and + * pb_release_single_field() unconditionally treated type->arg as a + * pb_msgdesc_t. This test covers both the custom-extension path (the bug) and + * the default-extension path (decode/encode NULL, arg is a descriptor), which + * must keep working. + * + * Hand-written descriptors, no protoc required. Build and run with: + * cc -I. pb_common.c pb_decode.c custom_extension.c -o custom_extension + * cc -DPB_ENABLE_MALLOC -I. pb_common.c pb_decode.c custom_extension.c ... + */ + +#include <stdio.h> +#include <string.h> +#include "pb_decode.h" + +/* ---- Custom extension scenario (issue #1200) ------------------------------- + * message Msg { optional int32 x = 1; extensions 100 to 199; } + * The descriptor below is what nanopb_generator writes for this message. */ + +typedef struct _Msg { bool has_x; int32_t x; pb_extension_t *extensions; } Msg; + +#define Msg_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, INT32, x, 1) \ +X(a, CALLBACK, OPTIONAL, EXTENSION, extensions, 100) +#define Msg_CALLBACK NULL +#define Msg_DEFAULT NULL +extern const pb_msgdesc_t Msg_msg; +PB_BIND(Msg, Msg, 2) + +static uint64_t seen_value; +static int seen; + +static bool my_decode(pb_istream_t *stream, pb_extension_t *ext, uint32_t tag, pb_wire_type_t wire_type) +{ + if (tag != 100 || wire_type != PB_WT_VARINT) + return true; /* not ours: leave it */ + ext->found = true; + seen = 1; + return pb_decode_varint(stream, &seen_value); +} + +static bool my_encode(pb_ostream_t *stream, const pb_extension_t *ext) +{ + (void) stream; + (void) ext; + return true; +} + +/* decode/encode non-NULL: type->arg is a free field, not a descriptor. */ +static const pb_extension_type_t my_type = {my_decode, my_encode, NULL}; + +static int test_custom_extension(void) +{ + /* field 1 (x) varint = 7, field 100 varint = 42 */ + static const pb_byte_t input[] = {0x08, 0x07, 0xa0, 0x06, 0x2a}; + /* field 1 (x) only, no extension field: exercises the found reset path */ + static const pb_byte_t input_empty[] = {0x08, 0x07}; + pb_extension_t ext = {&my_type, NULL, NULL, false}; + Msg msg; + pb_istream_t stream; + bool ok; + + seen = 0; + seen_value = 0; + memset(&msg, 0, sizeof msg); + msg.extensions = &ext; + stream = pb_istream_from_buffer(input, sizeof input); + ok = pb_decode(&stream, &Msg_msg, &msg); + if (!ok || !seen || seen_value != 42 || !ext.found) + return 1; + + /* Decoding again without the extension must reset ext->found in + * pb_field_set_to_default(). A custom type's arg is a free field, so it is + * skipped as a descriptor, but found must still be cleared. */ + stream = pb_istream_from_buffer(input_empty, sizeof input_empty); + ok = pb_decode(&stream, &Msg_msg, &msg); +#ifdef PB_ENABLE_MALLOC + pb_release(&Msg_msg, &msg); +#endif + return (ok && !ext.found) ? 0 : 1; +} + +/* ---- Default extension scenario (regression guard) ------------------------- + * extend Outer { optional int32 value = 100; } + * decode/encode NULL: type->arg points to a pb_msgdesc_t. */ + +typedef struct _ExtValue { bool has_value; int32_t value; } ExtValue; + +#define ExtValue_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, INT32, value, 100) +#define ExtValue_CALLBACK NULL +#define ExtValue_DEFAULT NULL +extern const pb_msgdesc_t ExtValue_msg; +PB_BIND(ExtValue, ExtValue, 2) + +typedef struct _Outer { pb_extension_t *extensions; } Outer; + +#define Outer_FIELDLIST(X, a) \ +X(a, CALLBACK, OPTIONAL, EXTENSION, extensions, 100) +#define Outer_CALLBACK NULL +#define Outer_DEFAULT NULL +extern const pb_msgdesc_t Outer_msg; +PB_BIND(Outer, Outer, 2) + +static const pb_extension_type_t ExtValue_type = {NULL, NULL, &ExtValue_msg}; + +static int test_default_extension(void) +{ + /* field 100 varint = 42 */ + static const pb_byte_t input[] = {0xa0, 0x06, 0x2a}; + ExtValue ext_value = {false, 0}; + pb_extension_t ext = {&ExtValue_type, &ext_value, NULL, false}; + Outer outer = {&ext}; + pb_istream_t stream = pb_istream_from_buffer(input, sizeof input); + bool ok; + + ok = pb_decode(&stream, &Outer_msg, &outer); +#ifdef PB_ENABLE_MALLOC + pb_release(&Outer_msg, &outer); +#endif + return (ok && ext.found && ext_value.value == 42) ? 0 : 1; +} + +int main(void) +{ + int status = 0; + + status |= test_custom_extension(); + status |= test_default_extension(); + + if (status) + printf("custom_extension: FAILED\n"); + else + printf("custom_extension: ok\n"); + + return status; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/cxx_callback_datatype/cxx_callback_datatype.cpp new/nanopb-0.4.9.3/tests/cxx_callback_datatype/cxx_callback_datatype.cpp --- old/nanopb-0.4.9.2/tests/cxx_callback_datatype/cxx_callback_datatype.cpp 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/cxx_callback_datatype/cxx_callback_datatype.cpp 2026-11-11 12:49:17.000000000 +0100 @@ -44,7 +44,6 @@ return true; } -extern "C" int main() { TestMessage source = TestMessage_init_zero; // Not strictly necessary to initialize, just using it to test the initializer. source.values.push_back(5); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/cxx_descriptor/message_descriptor.cc new/nanopb-0.4.9.3/tests/cxx_descriptor/message_descriptor.cc --- old/nanopb-0.4.9.2/tests/cxx_descriptor/message_descriptor.cc 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/cxx_descriptor/message_descriptor.cc 2026-11-11 12:49:17.000000000 +0100 @@ -2,7 +2,7 @@ #include "message.pb.h" #include "unittests.h" -extern "C" int main() { +int main() { using namespace nanopb; #if __cplusplus >= 201103L diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/enum_sizes/enum_intsize_unittests.cc new/nanopb-0.4.9.3/tests/enum_sizes/enum_intsize_unittests.cc --- old/nanopb-0.4.9.2/tests/enum_sizes/enum_intsize_unittests.cc 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/enum_sizes/enum_intsize_unittests.cc 2026-11-11 12:49:17.000000000 +0100 @@ -2,7 +2,7 @@ #include "enum_intsize.pb.hpp" #include "unittests.h" -extern "C" int main() +int main() { int status = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/fixed_count/fixed_count.proto new/nanopb-0.4.9.3/tests/fixed_count/fixed_count.proto --- old/nanopb-0.4.9.2/tests/fixed_count/fixed_count.proto 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/fixed_count/fixed_count.proto 2026-11-11 12:49:17.000000000 +0100 @@ -28,3 +28,11 @@ repeated SubMessage submsgs = 1 [(nanopb).type = FT_POINTER, (nanopb).max_count = 5, (nanopb).fixed_count = true]; repeated string strings = 2 [(nanopb).type = FT_POINTER, (nanopb).max_count = 4, (nanopb).fixed_count = true]; } + +message PointerSubMessage { + optional string str = 1 [(nanopb).type = FT_POINTER]; +} + +message Message5 { + repeated PointerSubMessage submsgs = 1 [(nanopb).max_count = 2, (nanopb).fixed_count = true]; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/fixed_count/fixed_count_unittests.c new/nanopb-0.4.9.3/tests/fixed_count/fixed_count_unittests.c --- old/nanopb-0.4.9.2/tests/fixed_count/fixed_count_unittests.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/fixed_count/fixed_count_unittests.c 2026-11-11 12:49:17.000000000 +0100 @@ -183,6 +183,52 @@ TEST(get_alloc_count() == 0); } + { + pb_byte_t input[] = {0x12, 0x01, 'a', 0x12, 0x01, 'b', 0x12, 0x01, 'c', + 0x12, 0x01, 'd', 0x12, 0x01, 'e'}; + pb_istream_t stream; + Message4 msg = Message4_init_zero; + + COMMENT("Test wrong number of entries in pointer type fixarray"); + + stream = pb_istream_from_buffer(input, 0); + TEST(pb_decode(&stream, Message4_fields, &msg)); + TEST(msg.strings == NULL); + pb_release(Message4_fields, &msg); + TEST(get_alloc_count() == 0); + + stream = pb_istream_from_buffer(input, 3); + TEST(!pb_decode(&stream, Message4_fields, &msg)); + TEST(strcmp(stream.errmsg, "wrong size for fixed count field") == 0); + TEST(get_alloc_count() == 0); + + stream = pb_istream_from_buffer(input, 15); + TEST(!pb_decode(&stream, Message4_fields, &msg)); + TEST(strcmp(stream.errmsg, "array overflow") == 0); + TEST(get_alloc_count() == 0); + } + + { + pb_byte_t input[] = {0x0a, 0x03, 0x0a, 0x01, 'a'}; + pb_istream_t stream; + Message5 msg; + + COMMENT("Test static fixarray of submessages with pointer fields"); + + memset(&msg, 0xAA, sizeof(msg)); + stream = pb_istream_from_buffer(input, 0); + TEST(pb_decode(&stream, Message5_fields, &msg)); + TEST(msg.submsgs[0].str == NULL && msg.submsgs[1].str == NULL); + pb_release(Message5_fields, &msg); + TEST(get_alloc_count() == 0); + + memset(&msg, 0xAA, sizeof(msg)); + stream = pb_istream_from_buffer(input, sizeof(input)); + TEST(!pb_decode(&stream, Message5_fields, &msg)); + TEST(strcmp(stream.errmsg, "wrong size for fixed count field") == 0); + TEST(get_alloc_count() == 0); + } + if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/float_double_conversion/float_double_conversion.c new/nanopb-0.4.9.3/tests/float_double_conversion/float_double_conversion.c --- old/nanopb-0.4.9.2/tests/float_double_conversion/float_double_conversion.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/float_double_conversion/float_double_conversion.c 2026-11-11 12:49:17.000000000 +0100 @@ -29,6 +29,16 @@ #define TESTVALUES_COUNT (sizeof(testvalues)/sizeof(testvalues[0])) +/* NaN payloads below, at and above the float mantissa cutoff. */ +static const uint8_t nanvalues[][8] = { + {1, 0, 0, 0, 0, 0, 0xF0, 0x7F}, + {1, 0, 0, 0, 0, 0, 0xF0, 0xFF}, + {0, 0, 0, 0x10, 0, 0, 0xF0, 0x7F}, + {0, 0, 0, 0x10, 0, 0, 0xF0, 0xFF}, + {0, 0, 0, 0x20, 0, 0, 0xF0, 0x7F}, + {0, 0, 0, 0x20, 0, 0, 0xF0, 0xFF} +}; + int main() { uint8_t buf[16]; @@ -86,5 +96,13 @@ } } + for (i = 0; i < sizeof(nanvalues) / sizeof(nanvalues[0]); i++) + { + float value; + pb_istream_t stream = pb_istream_from_buffer(nanvalues[i], sizeof(nanvalues[i])); + TEST(pb_decode_double_as_float(&stream, &value)); + TEST(isnan(value)); + } + return status; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/fuzztest/alltypes_callback.options new/nanopb-0.4.9.3/tests/fuzztest/alltypes_callback.options --- old/nanopb-0.4.9.2/tests/fuzztest/alltypes_callback.options 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/fuzztest/alltypes_callback.options 2026-11-11 12:49:17.000000000 +0100 @@ -2,3 +2,7 @@ *.oneof_* submsg_callback:true *.Limits.int64_min type:FT_CALLBACK *.DescriptorSize8 descriptorsize:DS_8 +*.callback_msg type:FT_CALLBACK +*.callback_val type:FT_CALLBACK +CBSubMessage.* type:FT_CALLBACK +*.oneof_msg_wcb type:FT_STATIC diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/fuzztest/fuzztest.c new/nanopb-0.4.9.3/tests/fuzztest/fuzztest.c --- old/nanopb-0.4.9.2/tests/fuzztest/fuzztest.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/fuzztest/fuzztest.c 2026-11-11 12:49:17.000000000 +0100 @@ -9,6 +9,7 @@ #include <pb_decode.h> #include <pb_encode.h> +#include <pb_common.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -372,6 +373,44 @@ #ifndef LLVMFUZZER +/* Check that size/count fields do not exceed their max size. + * Otherwise we would have to loop pretty long in generate_message(). + * Note that there may still be a few encoding errors from submessages. + */ +static void limit_sizes(alltypes_static_AllTypes *msg) +{ + pb_field_iter_t iter; + pb_field_iter_begin(&iter, alltypes_static_AllTypes_fields, msg); + while (pb_field_iter_next(&iter)) + { + if (PB_LTYPE(iter.type) == PB_LTYPE_BYTES) + { + ((pb_bytes_array_t*)iter.pData)->size %= iter.data_size - offsetof(pb_bytes_array_t, bytes); + } + + if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED) + { + *((pb_size_t*)iter.pSize) %= iter.array_size; + } + + if (PB_HTYPE(iter.type) == PB_HTYPE_ONEOF) + { + /* Set the oneof to this message type with 50% chance. */ + if (rand_word() & 1) + { + *((pb_size_t*)iter.pSize) = iter.tag; + } + + /* Make sure any callbacks are cleared */ + if (PB_ATYPE(iter.type) == PB_ATYPE_CALLBACK && + *((pb_size_t*)iter.pSize) == iter.tag) + { + memset(iter.pData, 0, iter.data_size); + } + } + } +} + static bool generate_base_message(uint8_t *buffer, size_t *msglen) { pb_ostream_t stream; @@ -386,6 +425,8 @@ while (rand_int(0, 7)) rand_mess((uint8_t*)msg, sizeof(alltypes_static_AllTypes)); + limit_sizes(msg); + msg->extensions = NULL; stream = pb_ostream_from_buffer(buffer, g_bufsize); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/fuzztest/generate_message.c new/nanopb-0.4.9.3/tests/fuzztest/generate_message.c --- old/nanopb-0.4.9.2/tests/fuzztest/generate_message.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/fuzztest/generate_message.c 2026-11-11 12:49:17.000000000 +0100 @@ -27,7 +27,7 @@ { if (PB_LTYPE(iter.type) == PB_LTYPE_BYTES) { - ((pb_bytes_array_t*)iter.pData)->size %= iter.data_size - PB_BYTES_ARRAY_T_ALLOCSIZE(0); + ((pb_bytes_array_t*)iter.pData)->size %= iter.data_size - offsetof(pb_bytes_array_t, bytes); } if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED) @@ -42,6 +42,13 @@ { *((pb_size_t*)iter.pSize) = iter.tag; } + + /* Make sure any callbacks are cleared */ + if (PB_ATYPE(iter.type) == PB_ATYPE_CALLBACK && + *((pb_size_t*)iter.pSize) == iter.tag) + { + memset(iter.pData, 0, iter.data_size); + } } } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/mem_release/mem_release.c new/nanopb-0.4.9.3/tests/mem_release/mem_release.c --- old/nanopb-0.4.9.2/tests/mem_release/mem_release.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/mem_release/mem_release.c 2026-11-11 12:49:17.000000000 +0100 @@ -236,9 +236,44 @@ return true; } +/* Decoding fails on a static repeated submessage entry before the entry has + * been initialized. The array contents are not cleared by pb_decode(), so the + * pointers in the entry must not be taken from the old memory contents. */ +static bool test_StaticRepeatedError() +{ + /* static_rep_submsg with wrong wire type */ + const uint8_t wrong_type[] = {0x20, 0x00}; + /* static_rep_submsg with length past the end of input */ + const uint8_t truncated[] = {0x22, 0x05}; + /* One valid entry with dynamic_str = "a", then wrong wire type */ + const uint8_t second_entry[] = {0x22, 0x03, 0x0A, 0x01, 0x61, 0x20, 0x00}; + + const struct { + const uint8_t *data; + size_t size; + } inputs[] = { + {wrong_type, sizeof(wrong_type)}, + {truncated, sizeof(truncated)}, + {second_entry, sizeof(second_entry)} + }; + size_t i; + + for (i = 0; i < sizeof(inputs) / sizeof(inputs[0]); i++) + { + TestMessage msg; + pb_istream_t stream = pb_istream_from_buffer(inputs[i].data, inputs[i].size); + memset(&msg, 0xAA, sizeof(msg)); + msg.extensions = NULL; + TEST(!pb_decode(&stream, TestMessage_fields, &msg)); + TEST(get_alloc_count() == 0); + } + + return true; +} + int main() { - if (test_TestMessage() && test_OneofMessage() && test_Garbage()) + if (test_TestMessage() && test_OneofMessage() && test_Garbage() && test_StaticRepeatedError()) return 0; else return 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/GHSA-fmpg-qc28-5x4x/SConscript new/nanopb-0.4.9.3/tests/regression/GHSA-fmpg-qc28-5x4x/SConscript --- old/nanopb-0.4.9.2/tests/regression/GHSA-fmpg-qc28-5x4x/SConscript 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/regression/GHSA-fmpg-qc28-5x4x/SConscript 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,9 @@ +# Regression test for security issue GHSA-fmpg-qc28-5x4x: +# "GHSA-p24j-vqcp-x988 fix is bypassable: callback inside oneof +# can result in call to attacker-controlled function pointer" + +Import("env") + +env.NanopbProto("oneof.proto") +p = env.Program(["oneof_callback_bug.c", "oneof.pb.c", "$COMMON/pb_decode.o", "$COMMON/pb_encode.o", "$COMMON/pb_common.o"]) +env.RunTest(p) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/GHSA-fmpg-qc28-5x4x/oneof.proto new/nanopb-0.4.9.3/tests/regression/GHSA-fmpg-qc28-5x4x/oneof.proto --- old/nanopb-0.4.9.2/tests/regression/GHSA-fmpg-qc28-5x4x/oneof.proto 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/regression/GHSA-fmpg-qc28-5x4x/oneof.proto 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,23 @@ +syntax = "proto3"; + +import "nanopb.proto"; + +message SubMsg1 +{ + string strvalue = 1; +} + +message SubMsg2 +{ + fixed32 intvalue = 1; +} + +message OneOfMessage +{ + oneof value + { + SubMsg1 submsg1 = 1 [(nanopb).type = FT_CALLBACK]; + SubMsg2 submsg2 = 2; + } +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/GHSA-fmpg-qc28-5x4x/oneof_callback_bug.c new/nanopb-0.4.9.3/tests/regression/GHSA-fmpg-qc28-5x4x/oneof_callback_bug.c --- old/nanopb-0.4.9.2/tests/regression/GHSA-fmpg-qc28-5x4x/oneof_callback_bug.c 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/regression/GHSA-fmpg-qc28-5x4x/oneof_callback_bug.c 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,55 @@ +/* Regression test for a bug in how callbacks inside oneofs were cleared */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <pb_encode.h> +#include <pb_decode.h> +#include <assert.h> +#include "oneof.pb.h" +#include "test_helpers.h" +#include "unittests.h" + +int main(int argc, char **argv) +{ + uint8_t msg1data[32]; + size_t msg1len = 0; + uint8_t msg2data[32]; + size_t msg2len = 0; + int status = 0; + + { + pb_ostream_t stream = pb_ostream_from_buffer(msg1data, sizeof(msg1data)); + pb_encode_tag(&stream, PB_WT_STRING, OneOfMessage_submsg2_tag); + pb_encode_varint(&stream, 5); + pb_encode_tag(&stream, PB_WT_32BIT, SubMsg2_intvalue_tag); + uint32_t value = 0xDEADBEEF; + pb_encode_fixed32(&stream, &value); + TEST(stream.bytes_written > 0); + msg1len = stream.bytes_written; + } + + { + pb_ostream_t stream = pb_ostream_from_buffer(msg2data, sizeof(msg2data)); + pb_encode_tag(&stream, PB_WT_STRING, OneOfMessage_submsg1_tag); + pb_encode_varint(&stream, 3); + pb_encode_tag(&stream, PB_WT_STRING, SubMsg1_strvalue_tag); + pb_byte_t charx = 'x'; + pb_encode_string(&stream, &charx, 1); + TEST(stream.bytes_written > 0); + msg2len = stream.bytes_written; + } + + { + pb_istream_t stream; + OneOfMessage msg = OneOfMessage_init_zero; + + stream = pb_istream_from_buffer(msg1data, msg1len); + TEST(pb_decode(&stream, OneOfMessage_fields, &msg)); + + stream = pb_istream_from_buffer(msg2data, msg2len); + TEST(pb_decode(&stream, OneOfMessage_fields, &msg)); + } + + return status; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/GHSA-p24j-vqcp-x988/poc_positive.c new/nanopb-0.4.9.3/tests/regression/GHSA-p24j-vqcp-x988/poc_positive.c --- old/nanopb-0.4.9.2/tests/regression/GHSA-p24j-vqcp-x988/poc_positive.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/GHSA-p24j-vqcp-x988/poc_positive.c 2026-11-11 12:49:17.000000000 +0100 @@ -38,6 +38,12 @@ pb_istream_t is = pb_istream_from_buffer(wire, sizeof wire); bool ok = pb_decode(&is, VariantMessage_fields, &msg); printf("[poc] pb_decode -> %d (%s)\n", ok, ok ? "ok" : PB_GET_ERROR(&is)); + +#ifdef PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS printf("[poc] RESULT: callback %s\n", fired ? "FIRED (correct)" : "DID NOT FIRE (REGRESSION)"); - return fired ? 0 : 1; + return (ok && fired) ? 0 : 1; +#else + printf("[poc] RESULT: callback %s\n", fired ? "FIRED (correct)" : "DID NOT FIRE (because of !PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS)"); + return ok ? 0 : 1; +#endif } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/fixed_count_submsg_callback/SConscript new/nanopb-0.4.9.3/tests/regression/fixed_count_submsg_callback/SConscript --- old/nanopb-0.4.9.2/tests/regression/fixed_count_submsg_callback/SConscript 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/regression/fixed_count_submsg_callback/SConscript 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,13 @@ +# Regression test for the fixed_count + submsg_callback combination: +# the generator must reject it instead of emitting an out-of-bounds +# submessage callback access. + +Import("env") + +import sys + +env = env.Clone() +env["PYTHON"] = env["ESCAPE"](sys.executable) +env.Command("test_fixed_count_submsg_callback.output", + "test_fixed_count_submsg_callback.py", + "$PYTHON $SOURCE > $TARGET") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/fixed_count_submsg_callback/test_fixed_count_submsg_callback.py new/nanopb-0.4.9.3/tests/regression/fixed_count_submsg_callback/test_fixed_count_submsg_callback.py --- old/nanopb-0.4.9.2/tests/regression/fixed_count_submsg_callback/test_fixed_count_submsg_callback.py 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/regression/fixed_count_submsg_callback/test_fixed_count_submsg_callback.py 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,68 @@ +# Regression test for the fixed_count + submsg_callback combination. +# +# submsg_callback stores a pb_callback_t in front of the field's _count +# (repeated) or which_ (oneof) member. A fixed count array has neither, so +# the generator used to still mark the field MSG_W_CB while emitting no +# callback slot. pb_dec_submessage()/pb_enc_submessage() then read the +# callback from (pb_callback_t*)field->pSize - 1, which points outside the +# message struct. The generator must reject the combination instead. + +import sys +from pathlib import Path + + +def find_repo_root(): + for start in (Path(__file__).resolve(), Path.cwd().resolve()): + for path in (start,) + tuple(start.parents): + if (path / "generator" / "nanopb_generator.py").is_file(): + return path + raise RuntimeError("could not find nanopb repository root") + + +sys.path.insert(0, str(find_repo_root())) + +from generator import nanopb_generator +from generator.proto import nanopb_pb2 + +FieldD = nanopb_generator.FieldD + + +def message_field(): + desc = nanopb_generator.descriptor.FieldDescriptorProto() + desc.name = "items" + desc.number = 1 + desc.label = FieldD.LABEL_REPEATED + desc.type = FieldD.TYPE_MESSAGE + desc.type_name = ".Sub" + return desc + + +def options(**kwargs): + opts = nanopb_pb2.NanoPBOptions() + for key, value in kwargs.items(): + setattr(opts, key, value) + return opts + + +def expect_fixed_count_rejected(): + try: + nanopb_generator.Field("Msg", message_field(), + options(max_count=2, fixed_count=True, submsg_callback=True)) + except Exception as exc: + assert "fixed_count" in str(exc) + assert "submsg_callback" in str(exc) + else: + raise AssertionError("fixed_count + submsg_callback was accepted") + + +def expect_repeated_still_works(): + field = nanopb_generator.Field("Msg", message_field(), + options(max_count=2, submsg_callback=True)) + assert field.pbtype == "MSG_W_CB" + assert field.rules == "REPEATED" + + +if __name__ == "__main__": + expect_fixed_count_rejected() + expect_repeated_still_works() + sys.stdout.write("ok\n") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_322/defaults.c new/nanopb-0.4.9.3/tests/regression/issue_322/defaults.c --- old/nanopb-0.4.9.2/tests/regression/issue_322/defaults.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_322/defaults.c 2026-11-11 12:49:17.000000000 +0100 @@ -17,6 +17,12 @@ TEST(msg->s1[0] == (char)0xC3 && msg->s1[1] == (char)0xA4 && msg->s1[2] == (char)0xC3 && msg->s1[3] == (char)0xB6 && msg->s1[4] == '\0'); + TEST(strcmp(msg->s2, "say \"hello\"") == 0); + TEST(memcmp(msg->s3, "\001a\002F\0030\0007", 9) == 0); + TEST(strcmp(msg->s4, "slash\\quote'line\n\r\t") == 0); + TEST(strcmp(msg->s5, "\303\251A9f\344\270\2550") == 0); + TEST(msg->s6[0] == '\0'); + TEST(strcmp(msg->s7, "\?\?/n") == 0); return status; } @@ -34,7 +40,7 @@ { DefaultsMsg msg = DefaultsMsg_init_zero; pb_istream_t empty = {0,0,0}; - pb_decode(&empty, DefaultsMsg_fields, &msg); + TEST(pb_decode(&empty, DefaultsMsg_fields, &msg)); COMMENT("Checking defaults set at runtime"); status += check_defaults(&msg); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_322/defaults.proto new/nanopb-0.4.9.3/tests/regression/issue_322/defaults.proto --- old/nanopb-0.4.9.2/tests/regression/issue_322/defaults.proto 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_322/defaults.proto 2026-11-11 12:49:17.000000000 +0100 @@ -6,6 +6,12 @@ optional bytes b2 = 2 [default = "\xDE\xAD\x00\xBE\xEF", (nanopb).max_size = 5]; optional bytes b3 = 3 [default = "\xDE\xAD\000\xBE\xEF", (nanopb).max_size = 15]; optional string s1 = 4 [default = "äö", (nanopb).max_size = 8]; + optional string s2 = 5 [default = "say \"hello\"", (nanopb).max_size = 16]; + optional string s3 = 6 [default = "\001a\002F\0030\0007", (nanopb).max_size = 9]; + optional string s4 = 7 [default = "slash\\quote'line\n\r\t", (nanopb).max_size = 32]; + optional string s5 = 8 [default = "éA9f中0", (nanopb).max_size = 10]; + optional string s6 = 9 [default = "", (nanopb).max_size = 1]; + optional string s7 = 10 [default = "??/n", (nanopb).max_size = 5]; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_453/test.c new/nanopb-0.4.9.3/tests/regression/issue_453/test.c --- old/nanopb-0.4.9.2/tests/regression/issue_453/test.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_453/test.c 2026-11-11 12:49:17.000000000 +0100 @@ -7,5 +7,8 @@ MyMessage msg = MyMessage_init_default; TEST(msg.myfield >= 1.23399f); TEST(msg.myfield <= 1.23401f); + TEST(msg.myfield2 == 1000000.0f); + TEST(msg.myfield3 >= 0.99999e-5f); + TEST(msg.myfield3 <= 1.00001e-5f); return status; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_453/test.proto new/nanopb-0.4.9.3/tests/regression/issue_453/test.proto --- old/nanopb-0.4.9.2/tests/regression/issue_453/test.proto 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_453/test.proto 2026-11-11 12:49:17.000000000 +0100 @@ -3,5 +3,9 @@ message MyMessage { optional float myfield = 1 [default = 1.234]; + + // protoc stores these as 1e+06 and 1e-05 + optional float myfield2 = 2 [default = 1000000]; + optional float myfield3 = 3 [default = 1e-5]; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_494/oneof_size.cc new/nanopb-0.4.9.3/tests/regression/issue_494/oneof_size.cc --- old/nanopb-0.4.9.2/tests/regression/issue_494/oneof_size.cc 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_494/oneof_size.cc 2026-11-11 12:49:17.000000000 +0100 @@ -1,7 +1,7 @@ #include "oneof.pb.h" #include "unittests.h" -extern "C" int main() +int main() { int status = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_838/enum_to_string.cxx new/nanopb-0.4.9.3/tests/regression/issue_838/enum_to_string.cxx --- old/nanopb-0.4.9.2/tests/regression/issue_838/enum_to_string.cxx 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_838/enum_to_string.cxx 2026-11-11 12:49:17.000000000 +0100 @@ -2,7 +2,7 @@ #include "unittests.h" #include "enum.pb.h" -extern "C" int main() +int main() { int status = 0; TEST(strcmp(MyEnum_name(MyEnum_VALUE1), "VALUE1") == 0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/regression/issue_954/test_options_diagnostics.py new/nanopb-0.4.9.3/tests/regression/issue_954/test_options_diagnostics.py --- old/nanopb-0.4.9.2/tests/regression/issue_954/test_options_diagnostics.py 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/regression/issue_954/test_options_diagnostics.py 2026-11-11 12:49:17.000000000 +0100 @@ -45,6 +45,19 @@ assert result[0][0] == "dir/file-name.proto" +def expect_fnmatch_patterns(): + options_file = NamedStringIO( + "dir/*.proto long_names:false\n" + "Message.field[1-2] max_size:16\n" + "Message.other/*comment*/ max_size:8\n" + ) + result = nanopb_generator.read_options_file(options_file) + + assert result[0][0] == "dir/*.proto" + assert result[1][0] == "Message.field[1-2]" + assert result[2][0] == "Message.other" + + def expect_comment_markers_in_strings(): options_file = NamedStringIO( "Message.url callback_datatype:\"http://example.com\" // trailing comment\n" @@ -61,5 +74,6 @@ if __name__ == "__main__": expect_invalid_pattern() expect_file_pattern() + expect_fnmatch_patterns() expect_comment_markers_in_strings() sys.stdout.write("ok\n") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/scons_tool/SConscript new/nanopb-0.4.9.3/tests/scons_tool/SConscript --- old/nanopb-0.4.9.2/tests/scons_tool/SConscript 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/scons_tool/SConscript 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,12 @@ +# Check availability detection through the SCons tool interface. + +Import("env") + +import sys + +env = env.Clone() +env["PYTHON"] = env["ESCAPE"](sys.executable) + +env.Command("test_scons_tool.output", + ["test_scons_tool.py", "#site_scons/site_tools/nanopb.py"], + '$PYTHON $SOURCES > $TARGET') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/scons_tool/test_scons_tool.py new/nanopb-0.4.9.3/tests/scons_tool/test_scons_tool.py --- old/nanopb-0.4.9.2/tests/scons_tool/test_scons_tool.py 1970-01-01 01:00:00.000000000 +0100 +++ new/nanopb-0.4.9.3/tests/scons_tool/test_scons_tool.py 2026-11-11 12:49:17.000000000 +0100 @@ -0,0 +1,24 @@ +import os.path +import sys +import unittest + +from SCons.Script import Environment +from SCons.Tool import Tool + + +class NanopbToolTests(unittest.TestCase): + def setUp(self): + self.env = Environment(tools=[]) + self.tool = Tool("nanopb", toolpath=[toolpath]) + + def test_available_tool_is_detected(self): + self.assertTrue(self.tool.exists(self.env)) + + def test_empty_protocflags_do_not_disable_tool(self): + self.env["PROTOCFLAGS"] = "" + self.assertTrue(self.tool.exists(self.env)) + + +if __name__ == "__main__": + toolpath = os.path.dirname(os.path.abspath(sys.argv.pop(1))) + unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/site_scons/platforms/avr/avr_io.c new/nanopb-0.4.9.3/tests/site_scons/platforms/avr/avr_io.c --- old/nanopb-0.4.9.2/tests/site_scons/platforms/avr/avr_io.c 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/site_scons/platforms/avr/avr_io.c 2026-11-11 12:49:17.000000000 +0100 @@ -11,6 +11,10 @@ #undef main extern int app_main(int argc, const char **argv); +// Declare weak symbols in case the main program is compiled as C++ +__attribute__((weak)) int _Z12app_mainiPPc(int argc, const char **argv) {return 0;}; +int app_main(int argc, const char **argv) __attribute__((weak, alias("_Z12app_mainiPPc"))); + struct { uint8_t argc; char args[3][16]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/site_scons/site_tools/nanopb.py new/nanopb-0.4.9.3/tests/site_scons/site_tools/nanopb.py --- old/nanopb-0.4.9.2/tests/site_scons/site_tools/nanopb.py 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/site_scons/site_tools/nanopb.py 2026-11-11 12:49:17.000000000 +0100 @@ -201,5 +201,5 @@ env['BUILDERS']['NanopbProtoCpp'] = _nanopb_proto_cpp_builder def exists(env): - return _detect_protoc(env) and _detect_protoc_opts(env) + return _detect_protoc(env) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tests/stackusage/SConscript new/nanopb-0.4.9.3/tests/stackusage/SConscript --- old/nanopb-0.4.9.2/tests/stackusage/SConscript 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tests/stackusage/SConscript 2026-11-11 12:49:17.000000000 +0100 @@ -1,7 +1,10 @@ # Test stack usage +# This test case intentionally performs access outside the legal stack area, +# so it may have to be skipped to avoid false positives on memory safety tools. Import("env") -env.NanopbProto(["stackusage", "stackusage.options"]) -test = env.Program(["stackusage.c", "stackusage.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) -env.RunTest(test) +if not env.get("NOUNSAFE"): + env.NanopbProto(["stackusage", "stackusage.options"]) + test = env.Program(["stackusage.c", "stackusage.pb.c", "$COMMON/pb_encode.o", "$COMMON/pb_decode.o", "$COMMON/pb_common.o"]) + env.RunTest(test) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tools/make_mac_package.sh new/nanopb-0.4.9.3/tools/make_mac_package.sh --- old/nanopb-0.4.9.2/tools/make_mac_package.sh 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tools/make_mac_package.sh 2026-11-11 12:49:17.000000000 +0100 @@ -8,7 +8,16 @@ set -e set -x -VERSION=`git describe --always`-macosx-x86 +ARCH=$(uname -m) +case "$ARCH" in + arm64|x86_64) ;; + *) + echo "Unsupported macOS architecture: $ARCH" >&2 + exit 1 + ;; +esac + +VERSION=$(git describe --always)-macosx-$ARCH if [[ "$VERSION" != nanopb* ]]; then VERSION="nanopb-0.0.0-$VERSION" fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/tools/make_windows_package.sh new/nanopb-0.4.9.3/tools/make_windows_package.sh --- old/nanopb-0.4.9.2/tools/make_windows_package.sh 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/tools/make_windows_package.sh 2026-11-11 12:49:17.000000000 +0100 @@ -29,6 +29,7 @@ cp $DEST/generator/dist/protoc/protoc.exe $DEST/generator-bin # Include Google's descriptor.proto and nanopb.proto +mkdir -p $DEST/generator-bin/grpc_tools/ cp -pr $(python3 -c 'import grpc_tools, os.path; print(os.path.dirname(grpc_tools.__file__))')/_proto $DEST/generator-bin/grpc_tools/ cp -pr $DEST/generator/proto $DEST/generator-bin/proto diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nanopb-0.4.9.2/zephyr/module.yml new/nanopb-0.4.9.3/zephyr/module.yml --- old/nanopb-0.4.9.2/zephyr/module.yml 2026-08-24 15:49:03.000000000 +0200 +++ new/nanopb-0.4.9.3/zephyr/module.yml 2026-11-11 12:49:17.000000000 +0100 @@ -8,5 +8,5 @@ - extra/requirements.txt security: external-references: - - cpe:2.3:a:nanopb_project:nanopb:0.4.9.2:*:*:*:*:*:*:* - - pkg:github/nanopb/[email protected] + - cpe:2.3:a:nanopb_project:nanopb:0.4.9.3:*:*:*:*:*:*:* + - pkg:github/nanopb/[email protected]
