Skip to content

Commit

Permalink
gossipstore: fix uninitialized input fd
Browse files Browse the repository at this point in the history
Initialize infd to STDIN_FILENO if the input file argument is missing.

Caught with gcc version: 7.4.0

devtools/create-gossipstore.c: In function ‘main’:
devtools/create-gossipstore.c:130:9: error: ‘infd’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  while (read_all(infd, &be_inlen, sizeof(be_inlen))) {

Suggested-by: @ZmnSCPxj <ElementsProject#2674 (comment)>
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 authored and rustyrussell committed Jun 3, 2019
1 parent 3f035cb commit 6f635b4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions devtools/create-gossipstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ int main(int argc, char *argv[])
if (infd < 0)
err(1, "opening %s", infile);
}
else
infd = STDIN_FILENO;

if (outfile) {
outfd = open(outfile, O_WRONLY|O_TRUNC|O_CREAT, 0666);
Expand Down

0 comments on commit 6f635b4

Please sign in to comment.