@@ -148,18 +148,14 @@ main(int argc, char *argv[])
148148
149149 /* signature is over variable name (no null), the vendor GUID, the
150150 * attributes, the timestamp and the contents */
151- int signbuflen = varlen + sizeof (EFI_GUID ) + sizeof (UINT32 ) + sizeof (EFI_TIME ) + st .st_size ;
151+ int signbuf_header_len = varlen + sizeof (EFI_GUID ) + sizeof (UINT32 ) + sizeof (EFI_TIME );
152+ int signbuflen = signbuf_header_len + st .st_size ;
152153 char * signbuf = malloc (signbuflen );
153- char * ptr = signbuf ;
154- memcpy (ptr , var , varlen );
155- ptr += varlen ;
156- memcpy (ptr , & vendor_guid , sizeof (vendor_guid ));
157- ptr += sizeof (vendor_guid );
158- memcpy (ptr , & attributes , sizeof (attributes ));
159- ptr += sizeof (attributes );
160- memcpy (ptr , & timestamp , sizeof (timestamp ));
161- ptr += sizeof (timestamp );
162- read (fdefifile , ptr , st .st_size );
154+ memcpy (signbuf , var , varlen );
155+ memcpy (signbuf + varlen , & vendor_guid , sizeof (EFI_GUID ));
156+ memcpy (signbuf + varlen + sizeof (EFI_GUID ), & attributes , sizeof (UINT32 ));
157+ memcpy (signbuf + varlen + sizeof (EFI_GUID ) + sizeof (UINT32 ), & timestamp , sizeof (EFI_TIME ));
158+ read (fdefifile , signbuf + signbuf_header_len , st .st_size );
163159
164160 printf ("Authentication Payload size %d\n" , signbuflen );
165161
@@ -194,7 +190,7 @@ main(int argc, char *argv[])
194190 /* first we write the authentication header */
195191 write (fdoutfile , var_auth , outlen );
196192 /* Then we write the payload */
197- write (fdoutfile , ptr , st .st_size );
193+ write (fdoutfile , signbuf + signbuf_header_len , st .st_size );
198194 /* so now the file is complete and can be fed straight into
199195 * SetVariable() as an authenticated variable update */
200196 close (fdoutfile );
0 commit comments