[hackers] [ii] don't modify argv, use a counter || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 18 Nov 2017 12:50:57 +0100 (CET)

commit 31b2445000b7f5f88e363f85de1e70e91c2adbaf
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Sat Nov 18 12:35:33 2017 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sat Nov 18 12:35:33 2017 +0100

    don't modify argv, use a counter
    
    on some platforms (OpenBSD) this changes the exposed argv in tools
    using the kvm_* interface, such as ps and pgrep.

diff --git a/arg.h b/arg.h
index e94e02b..fe4d7e5 100644
--- a/arg.h
+++ b/arg.h
_AT_@ -21,12 +21,13 @@ extern char *argv0;
                                         argc--;\
                                         break;\
                                 }\
- for (brk_ = 0, argv[0]++, argv_ = argv;\
- argv[0][0] && !brk_;\
- argv[0]++) {\
+ int i_;\
+ for (i_ = 1, brk_ = 0, argv_ = argv;\
+ argv[0][i_] && !brk_;\
+ i_++) {\
                                         if (argv_ != argv)\
                                                 break;\
- argc_ = argv[0][0];\
+ argc_ = argv[0][i_];\
                                         switch (argc_)
 
 #define ARGEND }\
Received on Sat Nov 18 2017 - 12:50:57 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 18 2017 - 13:00:39 CET