Browse Source

[zbin] Fix size used for memset in alloc_output_file

The output->buf field is a pointer, not an array, so sizeof() is not
applicable.  We must use the allocated string length instead.

Identified by gcc:

  util/zbin.c: In function ‘alloc_output_file’:
  util/zbin.c:146:37: warning: argument to ‘sizeof’ in ‘memset’ call
    is the same expression as the destination; did you mean to
    dereference it? [-Wsizeof-pointer-memaccess]
  memset ( output->buf, 0xff, sizeof ( output->buf ) );

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Daniel P. Berrange 11 years ago
parent
commit
eb5a2ba596
1 changed files with 1 additions and 1 deletions
  1. 1
    1
      src/util/zbin.c

+ 1
- 1
src/util/zbin.c View File

@@ -143,7 +143,7 @@ static int alloc_output_file ( size_t max_len, struct output_file *output ) {
143 143
 			  max_len );
144 144
 		return -1;
145 145
 	}
146
-	memset ( output->buf, 0xff, sizeof ( output->buf ) );
146
+	memset ( output->buf, 0xff, max_len );
147 147
 	return 0;
148 148
 }
149 149
 

Loading…
Cancel
Save