[PATCH] avoid future chance of using uninitialized memory

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Dec 19 23:53:36 CET 2014

* common/iobuf.c: (iobuf_open): initialize len


In iobuf_open, IOBUFCTRL_DESC and IOBUFCTRL_INIT commands are invoked
(via file_filter()) on fcx, passing in a pointer to an uninitialized

With these two commands, file_filter doesn't actually do anything with
the value of len, so there's no actual risk of use of uninitialized
memory in the code as it stands.

However, some static analysis tools might flag this situation with a
warning, and initializing the value doesn't hurt anything, so i think
this trivial cleanup is warranted.

Debian-Bug-Id: 773469
 common/iobuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/iobuf.c b/common/iobuf.c
index 3c68ce5..badbf78 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -1301,7 +1301,7 @@ iobuf_open (const char *fname)
   iobuf_t a;
   gnupg_fd_t fp;
   file_filter_ctx_t *fcx;
-  size_t len;
+  size_t len = 0;
   int print_only = 0;
   int fd;

More information about the Gnupg-devel mailing list