Handle invalid -U file format specifiers for input

The file format specifiers 'h', 'd', 'o', and 'b' are only valid for
outputting data. Reject them with a proper error message when
attempting to use them for input.
This commit is contained in:
Joerg Wunsch 2022-07-23 10:26:17 +02:00
parent affe4cb50a
commit 26f431c944
1 changed files with 28 additions and 0 deletions

View File

@ -278,6 +278,34 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
* write the selected device memory using data from a file; first
* read the data from the specified file
*/
const char *name = 0;
switch (upd->format) {
case FMT_HEX:
name = "hex";
break;
case FMT_DEC:
name = "decimal";
break;
case FMT_OCT:
name = "octal";
break;
case FMT_BIN:
name = "binary";
break;
default:
// no action needed
break;
}
if (name != 0) {
avrdude_message(MSG_INFO,
"%s: Invalid file format '%s' for input\n",
progname, name, upd->filename);
return -1;
}
if (quell_progress < 2) {
avrdude_message(MSG_INFO, "%s: reading input file \"%s\"\n",
progname,