From c144b5fa1be07cc2a15e4a85f45b3b9b60199260 Mon Sep 17 00:00:00 2001 From: Leon Lynch Date: Sun, 21 Jul 2024 20:44:20 +0200 Subject: [PATCH] Ensure that argp keys are not interpreted as short options The argp documentation indicates that if the key parameter has a value that is a printable ASCII value, it will also be used as the short option. Currently enums provide the key parameter for each option and there is no intention for these to be short options. Therefore it is best to renumber the enums to avoid printable ASCII values. --- tools/emv-decode.c | 2 +- tools/emv-tool.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/emv-decode.c b/tools/emv-decode.c index 91a6114..7a31d8f 100644 --- a/tools/emv-decode.c +++ b/tools/emv-decode.c @@ -46,7 +46,7 @@ static size_t arg_str_len = 0; // Decoding modes enum emv_decode_mode_t { - EMV_DECODE_NONE = 0, + EMV_DECODE_NONE = -255, // Negative value to avoid short options EMV_DECODE_ATR, EMV_DECODE_SW1SW2, EMV_DECODE_BER, diff --git a/tools/emv-tool.c b/tools/emv-tool.c index c8f2dba..cbf6198 100644 --- a/tools/emv-tool.c +++ b/tools/emv-tool.c @@ -52,7 +52,7 @@ static void emv_txn_load_config(struct emv_ctx_t* emv); // argp option keys enum emv_tool_param_t { - EMV_TOOL_PARAM_TXN_TYPE = 1, + EMV_TOOL_PARAM_TXN_TYPE = -255, // Negative value to avoid short options EMV_TOOL_PARAM_TXN_AMOUNT, EMV_TOOL_PARAM_TXN_AMOUNT_OTHER, EMV_TOOL_PARAM_DEBUG_VERBOSE,