-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base64: fix assignment to wrong type #56
base: master
Are you sure you want to change the base?
Conversation
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 <[email protected]>
@peterbarker Updated the PR to use |
👍 @rustyrussell please merge, then ElementsProject/libwally-core@bf81e8b will need a ccan-update |
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) {
| ^~ |
Thanks, applied! |
Found by gcc: