662 Commits

Author SHA1 Message Date
Robert Edmonds
0c5f04555a
Merge pull request #525 from defold/fix-unzip-on-windows
GitHub actions fail on Windows due to missing unzip command
2023-07-02 01:37:51 -04:00
Robert Edmonds
5c5a9981c0
Merge pull request #486 from franksinankaya/frkaya/linkorder
Makefile.am: change link order
2023-01-04 23:45:17 -05:00
Björn Ritzl
182953ead0 Use 7zip instead
7zip is installed on the GitHub runners: https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md#tools
2022-10-01 22:00:23 +02:00
Robert Edmonds
abc67a11c6 ChangeLog: 1.4.1 v1.4.1 2022-07-10 21:33:59 -04:00
Robert Edmonds
471aaa5f6d Bump copyright years to 2022 2022-07-10 21:33:59 -04:00
Robert Edmonds
a0a0131c89 Bump version to 1.4.1 2022-07-10 21:33:59 -04:00
Robert Edmonds
6d4eafd55f
Merge pull request #514 from protobuf-c/edmonds/issue512
Fix issue #512: clang analyzer 14 warning about a possible NULL deref.
2022-07-10 21:12:43 -04:00
Todd C. Miller
ab5f76a52b Fix a clang analyzer 14 warning about a possible NULL deref.
[edmonds: Import commit from
bfc6249902.patch.]
2022-07-10 20:39:06 -04:00
Robert Edmonds
ec3d900001
Merge pull request #513 from protobuf-c/edmonds/issue499
Fix issue #499: unsigned integer overflow
2022-07-10 20:37:15 -04:00
Todd C. Miller
0d1fd124a4 Fix regression with zero-length messages introduced in protobuf-c PR 500.
[edmonds: Import bugfix from
b6a6451482.patch.]
2022-07-10 20:09:23 -04:00
10054172
289f5c18b1 Fix issue #499: unsigned integer overflow
Signed-off-by: 10054172 <hui.zhang@thalesgroup.com>
2022-07-10 20:02:21 -04:00
Robert Edmonds
fc9b2b2ea9
Merge pull request #508 from millert/master
Only shift unsigned values to avoid implementation-specific behavior.
2022-07-10 19:57:15 -04:00
Todd C. Miller
6e389ce2c3 Only shift unsigned values to avoid implementation-specific behavior.
This converts the arithmetic shifts to logical shifts.
It is based in part on a stackoverflow answer by John Schultz,
https://stackoverflow.com/questions/4533076/google-protocol-buffers-zigzag-encoding
2022-06-06 13:57:38 -06:00
Sinan Kaya
d3651a3c50 Makefile.am: change link order
protoc depends on protobuf libraries for execution. Order libraries
accordingly. Observing link errors with yocto's meta-mingw project
during static linkage.

Signed-off-by: Sinan Kaya <sinan.kaya@microsoft.com>
2021-08-11 14:49:42 +03:00
Robert Edmonds
f224ab2eeb ChangeLog: 1.4.0 v1.4.0 2021-05-18 20:45:28 -04:00
Robert Edmonds
a124b38608 Bump version to 1.4.0 2021-05-18 20:28:48 -04:00
Ilya Lipnitskiy
9c0fdd12c3
Merge pull request #471 from protobuf-c/ga-pr
Run GitHub actions also on pull requests
2021-04-09 20:00:55 -07:00
Ilya Lipnitskiy
50851e47bc
Run GitHub actions also on pull requests
The push trigger didn't seem to work for PRs based in outside repos. So
limit the push trigger to master and next and enable a PR trigger.
2021-04-09 19:48:17 -07:00
Robert Edmonds
7c6b54b162
Merge pull request #467 from protobuf-c/issue-440
protobuf-c.c: fix packed repeated bool parsing
2021-04-06 20:18:34 -04:00
Robert Edmonds
1b6519e4a8
Merge pull request #466 from protobuf-c/options
protoc-c: add custom options support
2021-04-06 20:16:02 -04:00
Robert Edmonds
5ae0762b85
Merge branch 'next' into options 2021-04-06 19:57:36 -04:00
Robert Edmonds
53004955b0
Merge pull request #463 from protobuf-c/wiretype
protobuf-c: don't use ProtobufCWireType internally
2021-04-06 19:12:44 -04:00
Robert Edmonds
760c5daf03
Merge pull request #459 from protobuf-c/issue-458
protoc-c: fix shared lib build on windows, migrate from Travis CI to GitHub Actions
2021-04-06 18:31:47 -04:00
Ilya Lipnitskiy
733ae77e23
protobuf-c.c: fix packed repeated bool parsing
From https://developers.google.com/protocol-buffers/docs/proto3#updating:
  int32, uint32, int64, uint64, and bool are all compatible – this means
  you can change a field from one of these types to another without
  breaking forwards- or backwards-compatibility. If a number is parsed
  from the wire which doesn't fit in the corresponding type, you will
  get the same effect as if you had cast the number to that type in C++
  (e.g. if a 64-bit number is read as an int32, it will be truncated to
  32 bits).

Until this fix, protobuf-c did not conform to the rule above when it
came to deserializing non-boolean packed repeated data into a
protobuf_c_boolean array. Fully scan the varint and use parse_boolean to
truncate the resulting value.

Fixes #440
2021-03-28 12:27:51 -07:00
Ilya Lipnitskiy
7df109917a
protoc-c: add c_package option
This option allows to override the top-level 'package' setting, or even
remove the package prefix altogether (if set to "").

Fixes #322
2021-03-21 21:11:51 -07:00
Ilya Lipnitskiy
4f39ca6e0c
protoc-c: don't use FullName helpers for non-full names
FullName* methods are designed to split a full name based on '.' in the
name. name() does not have '.' separators, so call CamelToLower and
CamelToUpper in place of FullNameToLower and FullNameToUpper.
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
1b4e45e445
protoc-c: remove dead code 2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
f486c8ed66
protoc-c: add use_oneof_field_name option
Allows for generic oneof offset lookups based on the name of the oneof,
instead of having to know the field name. All oneof fields should have
the same offset, since they are members of a union.

Fixes #204
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
dfb6e300fa
protoc-c: add const_strings option
Keep default as false to preserve backwards compatibility.

Fixes #239
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
cebe3d03f9
protoc-c: add string as bytes option
Allows treating proto strings as ProtobufCBinaryData to work around
limitations such as NULL characters in strings, which are allowed in
protobuf, but not allowed in 'char *' types.

Fixes #203
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
6962695641
protoc-c: add option to customize base field name
Fixes #287
2021-03-21 21:11:50 -07:00
Ilya Lipnitskiy
baa860ff97
protoc-c: add options for function generation
Add options controller helper function generation. Preserve existing
behavior of not generating pack/unpack functions for sub-messages if
option is not explicitly set.

Fixes #240
Fixes #442
2021-03-21 21:11:49 -07:00
Ilya Lipnitskiy
883b1acc1b
protoc-c: add no_generate option
Allows suppression of .pb-c.{c,h} file generation on a .proto file
basis.

protobuf-c.proto: Use the new option in itself, because the options are
never used by protobuf-c runtime, only by the protoc-gen-c compiler.

t/test-full.proto: import protobuf-c.proto to test that
protobuf-c.pb-c.h dependency does not get included in test-full.pb-c.h.
2021-03-21 21:11:49 -07:00
Ilya Lipnitskiy
0e060260f0
protoc-c: add custom options support 2021-03-21 20:28:33 -07:00
Ilya Lipnitskiy
73a2ebefe6
Migrate from TravisCI to GitHub actions
We are now able to build against Mac and Windows.
But, mainly, see:
https://blog.travis-ci.com/2020-11-02-travis-ci-new-billing
https://docs.travis-ci.com/user/migrate/open-source-on-travis-ci-com/
2021-03-21 13:57:22 -07:00
Ilya Lipnitskiy
e79f7d3ac6
cmake: use static build by default, fix MSVC build
Matches protobuf default behavior:
https://github.com/protocolbuffers/protobuf/tree/master/cmake#dlls-vs-static-linking

Bump min cmake version to use Protobuf_USE_STATIC_LIBS:
https://cmake.org/cmake/help/latest/module/FindProtobuf.html
2021-03-15 18:01:47 -07:00
Ilya Lipnitskiy
18ede005af
protobuf-c.{c,h}: use static empty_string on WIN32
MSVC has issues importing protobuf_c_empty_string from the DLL and using
it in initializers, resulting in errors like when linking against
protobuf-c.dll:
  test-proto3.pb-c.c(13): error C2099: initializer is not a constant
  test-proto3.pb-c.c(19): error C2440: 'initializing': cannot convert from 'void *' to 'Foo__Person__PhoneType'

Work around the issue by not exporting protobuf_c_empty string and
defining it as static const char[] in the protobuf-c.h file itself. This
change only applies to _WIN32 shared library builds.
2021-03-15 18:01:47 -07:00
Ilya Lipnitskiy
d9f098e3ab
Revert "protobuf-c.h: Fix Windows DLL export (Fixes #331)"
This reverts commit 4c8043d02659d18937447d53b38e6bb029cf8e62.
2021-03-15 18:01:47 -07:00
Ilya Lipnitskiy
2a278e0756
protoc-c: fix shared lib build on windows
Fixes #458

Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
2021-03-15 18:01:47 -07:00
Ilya Lipnitskiy
d97abfaea2
protobuf-c: don't use ProtobufCWireType internally
protobuf-c parsing code operates on wire type as uint8_t, so keep it
defined as such to avoid confusion and unnecessary compiler warnings.
2021-03-11 18:13:54 -08:00
Robert Edmonds
38af0d26ab
Merge pull request #453 from wolframroesler/no-unused-parameter
Avoid "unused function parameter" compiler warning
2021-02-18 21:36:05 -05:00
Wolfram Rösler
a60f2680d2
Avoid "unused function parameter" compiler warning 2021-02-18 18:33:24 -08:00
Robert Edmonds
1afa3f67b0
Merge pull request #455 from ihsinme/patch-1
fix invalid unsigned arithmetic.
2021-02-18 21:30:57 -05:00
Robert Edmonds
32f0a781c7
Merge pull request #456 from ppietrasa/master
Install debug symbols alongside the protobuf-c.lib
2021-02-18 21:21:46 -05:00
ihsinme
abca6f6cb6 fix invalid unsigned arithmetic. 2021-02-10 11:41:38 +03:00
Piotr Pietraszkiewicz
f53a8c98ad Install debug symbols alongside the protobuf-c.lib
A user of the protobuf-c library is confronted with MSVC warnings about missing
PDB if the library happens to be built/configured using the CMAKE_BUILD_TYPE
"Debug" or "RelWithDebInfo". This commit deals away with the warning by
installing the "protobuf-c.pdb" alongside the lib. The .pdb is installed only
if it exists. Configuring "Release" or building under Linux won't produce and
won't install the PDB.
2021-02-08 13:58:52 +01:00
Robert Edmonds
94532c7a63
Merge pull request #443 from acozzette/std-string
Updated the generator to fully qualify std::string
2020-10-16 20:03:05 -04:00
Adam Cozzette
3d2ed0d410 Updated the generator to fully qualify std::string
The protobuf common.h header currently has a "using std::string;"
statement that pulls std::string into the google::protobuf namespace:
ce66f6047d/src/google/protobuf/stubs/common.h (L195)

I plan to delete that line soon. To keep protobuf-c working, this commit
updates the generator to fully qualify std::string.
2020-10-16 16:45:21 -07:00
Robert Edmonds
5f2484642b
Merge pull request #438 from daxtens/next
Travis CI: Test on other platforms
2020-09-06 17:29:43 -04:00
Daniel Axtens
50cec74c8b travis: Test across a range of platforms
Travis CI now supports testing on arm64, ppc64le and s390x. It would
be nice to test on them.

Signed-off-by: Daniel Axtens <dja@axtens.net>
2020-07-23 11:18:14 +10:00
Daniel Axtens
ae76c6590f travis: Bump distro version to Bionic
Bionic contains more recent compilers, which are required to have
the sanitisers work under s390x.

While we're at it, the 'sudo' key is deprecated, so remove it:

https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration

(It used to be used to mark VM vs docker container infrastructure,
but currently all amd64 builds run on VMs and all other archs run
inside LXD containers.)

Signed-off-by: Daniel Axtens <dja@axtens.net>
2020-07-23 11:11:44 +10:00
Robert Edmonds
19abc46140
Merge pull request #431 from SeRoSystems/dev/inline
Pack nested messages inline
2020-06-20 16:01:47 -04:00
Robert Edmonds
d18a21d5ba
Merge pull request #430 from protobuf-c/ilya-underscore
protoc-c: Remove leading underscores from structs
2020-06-20 15:56:46 -04:00
Robert Edmonds
cf04fa717e
Merge pull request #429 from protobuf-c/ilya-357
protobuf-c.c: Cast %lu args to unsigned long int
2020-06-20 15:51:49 -04:00
Robert Edmonds
bca6ced64d
Merge pull request #425 from protobuf-c/ilya-cmake
Standardize pkg-config for use by autotools and cmake, fix cmake tests
2020-06-20 15:49:27 -04:00
Robert Edmonds
6d08d99dec
Merge pull request #428 from protobuf-c/ilya-331
protobuf-c.h: Fix Windows DLL export (Fixes #331)
2020-06-20 15:29:03 -04:00
Robert Edmonds
cc79026e82
Merge pull request #427 from protobuf-c/ilya-oneof
c_message.cc: Resolve name conflict (Fixes #389)
2020-06-20 15:26:19 -04:00
Markus Engel
2804820230 Pack nested messages inline
Signed-off-by: Markus Engel <engel@sero-systems.de>
2020-05-14 12:30:51 +02:00
Ilya Lipnitskiy
cd671dbc3d protobuf-c.c, protoc-c: Remove leading underscores
Fixes #188.

Implements suggested fix from the issue:
The struct tag namespace is different from the type namespace. Use the
same symbol names (i.e. without leading underscores) in every namespace.
2020-05-13 15:30:20 -07:00
dota17
5af12e4581 Added instructions for testing in README 2020-05-13 14:37:51 -07:00
Ilya Lipnitskiy
2102d3a2c5 CMakeLists.txt: Don't include Dart if no tests
Also use BUILD_TESTS instead of CMAKE_BUILD_TYPE in other places in the
file.
2020-05-13 13:38:34 -07:00
Ilya Lipnitskiy
4c86c6b333 Add test for #389 2020-05-13 13:20:48 -07:00
Ilya Lipnitskiy
e43ed4f01d protobuf-c.c: Cast %lu args to unsigned long int
Resolves an ambiguity that %zu was meant to address, since %zu is not
present on all platforms.

Fixes #357.
2020-05-13 10:52:15 -07:00
Ilya Lipnitskiy
4c8043d026 protobuf-c.h: Fix Windows DLL export (Fixes #331)
protobuf_c_empty_string is used in generated .pb-c.{c,h} files so it
should be exported properly.
2020-05-12 17:54:15 -07:00
Ilya Lipnitskiy
93afe2d52d c_message.cc: Resolve name conflict (Fixes #389) 2020-05-12 12:21:48 -07:00
James Benton
e01b30d4fe Add BUILD_TESTS option to CMake build. 2020-05-12 10:21:30 -07:00
Ilya Lipnitskiy
56b8d915be Move Doxygen back to GitHub domain
lib.protobuf-c.io is no longer reachable.
2020-05-09 15:23:27 -07:00
Ilya Lipnitskiy
12973e7f3f CMakeLists.txt: Add option to disable protoc-gen-c 2020-05-09 15:08:28 -07:00
Ilya Lipnitskiy
3d3b5fe220 CMakeLists.txt: Enforce C++11 for old compilers 2020-05-09 14:29:06 -07:00
Ilya Lipnitskiy
ce75229b6a CMakeLists.txt: Fix protoc-c crashes on Linux
-lpthread was missing from the linker command line. See
https://github.com/protocolbuffers/protobuf/issues/5107 for more
details.

.travis.yml: Run CMake debug build for verification
2020-05-09 13:27:33 -07:00
Ilya Lipnitskiy
db6c49cc43 CMakeLists.txt: Add pkg-config logic (Fixes #339) 2020-05-09 13:27:23 -07:00
Ilya Lipnitskiy
d6eaa410b6 libprotobuf-c.pc.in: Add URL, use standard macros
PACKAGE_DESCRIPTION is defined in configure.ac. PACKAGE_NAME,
PACKAGE_VERSION, and PACKAGE_URL come from AC_INIT.

This change will ensure that libprotobuf-c.pc.in could also be used by
CMake.
2020-05-08 18:52:42 -07:00
Robert Edmonds
39cd58f5ff
Merge pull request #399 from protobuf-c/edmonds/version/1.3.3
Bump version to 1.3.3
2020-02-13 18:43:35 -05:00
Robert Edmonds
f20a3fa131 ChangeLog: 1.3.3 v1.3.3 2020-02-13 18:42:42 -05:00
Robert Edmonds
d0531beaad Bump version to 1.3.3 2019-12-04 16:08:05 -05:00
Robert Edmonds
e7c18ecda7
Merge pull request #350 from msshapira/patch-2
fix suport for MSVC static build
2019-12-04 13:35:36 -05:00
Markus Engel
687f27726c Fixed endianness check for cmake
Signed-off-by: Markus Engel <engel@sero-systems.de>
2019-10-18 21:23:55 -04:00
Robert Edmonds
ef868b712f
Merge pull request #400 from protobuf-c/ilya-zigzag
protobuf-c.c: Make zigzag encoding more compact
2019-10-18 21:21:27 -04:00
Robert Edmonds
ff04761e39
Merge pull request #392 from acozzette/fix-test-asserts
Fixed some test assertions in test-generated-code2.c
2019-10-18 21:15:21 -04:00
Robert Edmonds
1f3d4e2e94
Merge pull request #378 from protobuf-c/ilya/coverage
.travis.yml: Reenable code coverage
2019-10-18 21:14:22 -04:00
Ilya Lipnitskiy
66e8aa5ed3 protobuf-c.c: Make zigzag encoding more compact
Also match upstream code in src/google/protobuf/wire_format_lite.h
2019-10-18 10:40:24 -07:00
Robert Edmonds
9f89e64083
Merge pull request #398 from protobuf-c/edmonds/issue330-requires-proto3
Makefile.am: Only enable the Issue #330 test case when building against protobuf 3.x
2019-10-17 20:19:43 -04:00
Robert Edmonds
dc3057c840 Makefile.am: Only enable the Issue #330 test case when building against protobuf 3.x
Issue #330 is a bug in proto3 behavior and the test case handling it
needs a 'syntax = "proto3";' line in its .proto file, which is not
supported by the protobuf 2 implementation.

Since we still support building against protobuf 2, this commit
conditionalizes the Issue #330 test case so that it is only built when
protobuf-c is being built against protobuf 3.
2019-10-17 19:01:35 -04:00
Adam Cozzette
5ee9afdc15 Fixed some test assertions in test-generated-code2.c
I fixed a couple test assertions here that seemed to be accidentally
using assignment (=) instead of equality (==).
2019-08-27 11:07:26 -07:00
Robert Edmonds
1390409f4e
Merge pull request #384 from protobuf-c/edmonds/version/1.3.2
Bump version to 1.3.2
v1.3.2
2019-06-24 01:07:52 -04:00
Robert Edmonds
1f68c67e15 ChangeLog: 1.3.2 2019-06-24 00:52:57 -04:00
Robert Edmonds
62ecf2b467 Bump version to 1.3.2 2019-06-24 00:37:47 -04:00
Ilya Lipnitskiy
8f92882d4b .travis.yml: Reenable code coverage
Code coverage option was removed in the xenial update change (fe36c1677)
2019-05-20 10:49:27 -07:00
Robert Edmonds
d712e0c52d
Merge pull request #299 from guerital/tag-zero-fix
Check if tag is equal to 0
2019-05-18 18:06:19 -04:00
Robert Edmonds
4a7fde66fc Fix whitespace error in previous commit 2019-05-18 17:52:58 -04:00
Robert Edmonds
a6556fb372
Merge pull request #358 from ugurkoltuk-adyen/ugurkoltuk-adyen/message_check_fix
Fix a SEGV on on protobuf_c_message_check on messages with 'oneof's inside
2019-05-18 17:52:13 -04:00
Jurriaan Bremer
b8cd15a84f protobuf-c: Fix -Wdeclaration-after-statement warning in parse_oneof_member()
* allow compilation with -pedantic (thanks @Bun)

Can be reproduced with the following command:

$ make CFLAGS=-pedantic protobuf-c/protobuf-c.o

* put el-size on a separate line
2019-05-18 17:47:23 -04:00
Robert Edmonds
c404ce3eb0
Merge pull request #377 from protobuf-c/ilya/issue330
Fix proto3 repeated scalar field default packing behavior (#330)
2019-05-18 17:16:37 -04:00
Robert Edmonds
ffe38d4df5
Merge branch 'next' into ilya/issue330 2019-05-18 17:02:29 -04:00
Robert Edmonds
2f98c76676
Merge pull request #376 from acozzette/fix-375
Fixed out-of-bounds read (#375)
2019-05-18 16:43:15 -04:00
Ilya Lipnitskiy
69c39824cf protoc-c/c_field.cc: Fix proto3 field packing #330
Fixes #330 and makes scalar repeated fields packed by default in proto3.

https://developers.google.com/protocol-buffers/docs/encoding#packed:
In proto3, repeated fields of scalar numeric types are packed by
default.
2019-05-17 13:29:06 -07:00
Ilya Lipnitskiy
6aa7dc7a10 Add test case for #330 2019-05-17 13:29:06 -07:00
Adam Cozzette
d58d7ca271 Fixed out-of-bounds read
The scan_length_prefixed_data() function returns the number of bytes
taken up by a varint length delimiter, plus the actual value of that
delimiter. Since it returns a uint32_t, a delimiter of 2^32 - 1 (or
close to that) could cause the return value to overflow and result in an
incorrect value.

At first I tried to fix it by making scan_length_prefixed_data() use a
size_t for its result, but I realized this would have no effect on
32-bit systems. To fix the problem for 32-bit, I changed the function to
return early if the length is 2 GiB or more (protobuf messages are not
allowed to be that large). I kept the size_t change anyway, since the
result will ultimately be stored in a size_t (ScannedMember.len) and we
might as well stay consistent with that.

Signed-off-by: Adam Cozzette <acozzette@google.com>
2019-05-16 12:30:08 -07:00
Hayri Ugur Koltuk
ad6952d9f2 Add test case for protobuf_c_check SEGV on unpopulated oneof member
Signed-off-by: Hayri Ugur Koltuk <ugur.koltuk@adyen.com>
2019-04-16 09:30:08 +02:00
Robert Edmonds
9412830d06
Merge pull request #369 from protobuf-c/edmonds/protobuf-reflection-typedef-test-fix
t/generated-code2/cxx-generate-packed-data.cc: Fix build failure on newer protobuf
2019-04-10 21:43:03 -04:00