Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
broker: avoid accidentally consuming % format characters in initial program args #2285
This issue could have also been fixed by simply calling
as one would do for
Problem: Because the flux_cmd_argv_append() function takes printf style format string and arguments, it suffers from the same problem as printf(3) when a variable is passed directly to the fmt argument, as in flux_cmd_argv_append (cmd, arg); since `arg` may contain a '%' character. Possibly because of the function name, several spots in flux-core call `flux_cmd_argv_append` just as shown above. This resulted in a bug where '%h' and other characters preceeded by '%' can't be passed through the `flux start` and `flux broker` command line. To fix, rename `flux_cmd_argv_append` to `flux_cmd_argv_appendf` to more strongly indicate that this is a printf style function. Add a new `flux_cmd_argv_append()` which now takes a single string argument. Update the few callers that needed the varargs `flux_cmd_argv_appendf`. Fixes #2284
Add __attribute__ ((format (printf, ...))) to flux_cmd_setenvf() and flux_cmd_argv_appendf() to guard against callers calling these functions with improper printf format style arguments. This protects against bugs common with this style of arguments. Fix a couple places in the code that were improperly calling these functions, as caught by the new attribute.
@@ Coverage Diff @@ ## master #2285 +/- ## ========================================== + Coverage 80.79% 80.83% +0.03% ========================================== Files 213 213 Lines 33475 33484 +9 ========================================== + Hits 27047 27066 +19 + Misses 6428 6418 -10
On Sat, Aug 3, 2019, 9:09 AM Jim Garlick ***@***.***> wrote: LGTM! Ready to merge? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#2285?email_source=notifications&email_token=AAFVEUQP3QX2P7WQFC5SDE3QCWUUDA5CNFSM4IJCHZT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PRF6Y#issuecomment-517935867>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAFVEUXJG264LIKVLMOJZ3TQCWUUDANCNFSM4IJCHZTQ> .