@@ -2008,15 +2008,21 @@ int main(int argc, char** argv)
20082008 tag = (uint16_t )arg2num (argv [i + 1 ], 2 );
20092009 len = (uint16_t )arg2num (argv [i + 2 ], 2 );
20102010
2011- if (( tag < 0x0030 ) || ( tag > 0xFEFE ) ) {
2011+ if (tag < 0x0030 ) {
20122012 fprintf (stderr , "Invalid custom tag: %s\n" , argv [i + 1 ]);
20132013 exit (16 );
20142014 }
2015+ if ( ((tag & 0xFF00 ) == 0xFF00 ) || ((tag & 0xFF ) == 0xFF ) ) {
2016+ fprintf (stderr , "Invalid custom tag: %s\n" , argv [i + 1 ]);
2017+ exit (16 );
2018+ }
2019+
20152020 if ((len != 1 ) && (len != 2 ) && (len != 4 ) && (len != 8 )) {
20162021 fprintf (stderr , "Invalid custom tag len: %s\n" , argv [i + 2 ]);
20172022 fprintf (stderr , "Accepted len: 1, 2, 4 or 8\n" );
20182023 exit (16 );
20192024 }
2025+
20202026 CMD .custom_tlv [p ].tag = tag ;
20212027 CMD .custom_tlv [p ].len = len ;
20222028 CMD .custom_tlv [p ].val = arg2num (argv [i + 3 ], len );
@@ -2031,12 +2037,20 @@ int main(int argc, char** argv)
20312037 fprintf (stderr , "Too many custom TLVs.\n" );
20322038 exit (16 );
20332039 }
2034- if (argc < (i + 3 )) {
2040+ if (argc < (i + 2 )) {
20352041 fprintf (stderr , "Invalid custom TLV fields. \n" );
20362042 exit (16 );
20372043 }
20382044 tag = (uint16_t )arg2num (argv [i + 1 ], 2 );
20392045 len = (uint16_t )strlen (argv [i + 2 ]) / 2 ;
2046+ if (tag < 0x0030 ) {
2047+ fprintf (stderr , "Invalid custom tag: %s\n" , argv [i + 1 ]);
2048+ exit (16 );
2049+ }
2050+ if ( ((tag & 0xFF00 ) == 0xFF00 ) || ((tag & 0xFF ) == 0xFF ) ) {
2051+ fprintf (stderr , "Invalid custom tag: %s\n" , argv [i + 1 ]);
2052+ exit (16 );
2053+ }
20402054 if (len > 255 ) {
20412055 fprintf (stderr , "custom tlv buffer size too big: %s\n" , argv [i + 2 ]);
20422056 exit (16 );
0 commit comments