Skip to content

Commit

Permalink
sign-file: Fix inplace signing when src and dst names are both specified
Browse files Browse the repository at this point in the history
When src and dst both are specified and they point to the same file
the sign-file utility will write only signature to the dst file and
the module (.ko file) body will not be written.
That happens because we open the same file with "rb" and "wb" flags,
from fopen man:

 w      Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
...
	bm = BIO_new_file(module_name, "rb");
...
	bd = BIO_new_file(dest_name, "wb");
...
	while ((n = BIO_read(bm, buf, sizeof(buf))),
	       n > 0) {
		ERR(BIO_write(bd, buf, n) < 0, "%s", dest_name);
	}
...

Signed-off-by: Alex Yashchenko <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
alexhoppus authored and herbertx committed Dec 14, 2016
1 parent fbb7263 commit efcae7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/sign-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ int main(int argc, char **argv)
}
x509_name = argv[2];
module_name = argv[3];
if (argc == 5) {
if (argc == 5 && strcmp(argv[3], argv[4]) != 0) {
dest_name = argv[4];
replace_orig = false;
} else {
Expand Down

0 comments on commit efcae7c

Please sign in to comment.