[hackers] [sbase] xinstall: Fix broken memmove with -t || Michael Forney

From: <git_AT_suckless.org>
Date: Tue, 27 Dec 2016 15:04:02 +0100 (CET)

commit b7fb3a58e7ec12987706fd52f5361a944ddc1da8
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Tue Dec 27 13:48:31 2016 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Tue Dec 27 13:48:59 2016 +0100

    xinstall: Fix broken memmove with -t
    
    memmove moves a number of bytes, not pointers, so if you passed a number
    of arguments that is larger than the pointer byte size, you could
    end up crashing or skipping the install of a file and installing another
    twice.
    
    Also, argv was never decreased to match the moved arguments, so the -t
    parameter was added in the NULL argv slot.

diff --git a/xinstall.c b/xinstall.c
index 70d7097..38636f1 100644
--- a/xinstall.c
+++ b/xinstall.c
_AT_@ -219,7 +219,7 @@ main(int argc, char *argv[])
                 mode = parsemode(mflag, mode, 0);
 
         if (tflag) {
- memmove(argv - 1, argv, argc);
+ argv = memmove(argv - 1, argv, argc * sizeof(*argv));
                 argv[argc++] = tflag;
         }
         if (tflag || argc > 2) {
Received on Tue Dec 27 2016 - 15:04:02 CET

This archive was generated by hypermail 2.3.0 : Tue Dec 27 2016 - 15:13:27 CET