From: Alex Yashchenko Date: Tue, 13 Dec 2016 09:26:25 +0000 (+0000) Subject: sign-file: Fix inplace signing when src and dst names are both specified X-Git-Tag: Ubuntu-4.10.0-7.9~917^2~1 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=efcae7c931b473285e38c778bdaa9f36de9f78d6;p=mirror_ubuntu-zesty-kernel.git sign-file: Fix inplace signing when src and dst names are both specified 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 Signed-off-by: David Howells Signed-off-by: Herbert Xu --- diff --git a/scripts/sign-file.c b/scripts/sign-file.c index 53af6dc3e6c1..19ec468b1168 100755 --- a/scripts/sign-file.c +++ b/scripts/sign-file.c @@ -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 {