Skip to content

Commit

Permalink
Ensure that argp keys are not interpreted as short options
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
leonlynch committed Jul 21, 2024
1 parent fb0780c commit c144b5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/emv-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tools/emv-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c144b5f

Please sign in to comment.