base64: fix assignment to wrong type#56
Open
mmilata wants to merge 1 commit into
Open
Conversation
Collaborator
|
On Thu, May 11, 2017 at 09:40:28AM -0700, Martin Milata wrote:
Found by gcc:
```
base64.c:196:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (more == -1) {
^
```
You can view, comment on, or merge this pull request online at:
So, I guess that's right in a sense, but it just exposes a bug in the
called function - that returns an int value derived from a size_t,
which could be truncated on a 64-bit platform. I think that needs to
change to ssize_t.
Peter (module author), can you have a look at this.
…
#56
-- Commit Summary --
* base64: fix assignment to wrong type
-- File Changes --
M ccan/base64/base64.c (2)
-- Patch Links --
https://github.com/rustyrussell/ccan/pull/56.patch
https://github.com/rustyrussell/ccan/pull/56.diff
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
|
|
From program flow maximum size of the parameter is 3, so overflow is unlikely. Changing it to return @mmilata Do you think changing the return type to |
Functions that returned int have been modified to return ssize_t
instead.
Found by gcc:
base64.c:196:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (more == -1) {
^
Signed-off-by: Martin Milata <martin@martinmilata.cz>
Contributor
Author
|
@peterbarker Updated the PR to use |
Contributor
|
👍 @rustyrussell please merge, then ElementsProject/libwally-core@bf81e8b will need a ccan-update |
Contributor
|
Just that it would be nicer without the warning… =) ../../../libwally-core/src/ccan/ccan/base64/base64.c: In function 'base64_decode_using_maps':
../../../libwally-core/src/ccan/ccan/base64/base64.c:196:11: warning: comparison
of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'}
and 'int' [-Wsign-compare]
196 | if (more == -1) {
| ^~ |
peterbarker
approved these changes
Apr 26, 2021
Owner
|
Thanks, applied! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by gcc: