diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-23 21:58:47 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-23 21:58:47 -0500 |
commit | 06bcc5b5773b744994abda1424369df24e332e2c (patch) | |
tree | e9da482051bfa6060194423fd359af11b37e50a4 /uxd.c | |
parent | 8a34d1a58b9f750ead06190a33c43385c829e428 (diff) | |
download | uxd-06bcc5b5773b744994abda1424369df24e332e2c.tar.gz |
do not dump past end of -d argument
Diffstat (limited to 'uxd.c')
-rw-r--r-- | uxd.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -635,8 +635,12 @@ int get_next_byte(void) { if(dump_data_arg) { /* have to cast this to unsigned char and back to int, to emulate fgetc() */ - c = (unsigned char)dump_data_arg[dump_data_idx++]; - if(!c) c = EOF; + c = (unsigned char)dump_data_arg[dump_data_idx]; + if(c) { + dump_data_idx++; + } else { + c = EOF; + } } else { c = fgetc(input); } @@ -863,6 +867,7 @@ void seek_input(void) { } } +/* -i */ void print_info(void) { printf("\nBytes: %ld\n", byte_count); printf("Valid characters: %ld\n", char_count); @@ -890,6 +895,7 @@ void dump_file(void) { fclose(input); } +/* -d */ void dump_data(void) { int datalen; @@ -927,7 +933,7 @@ int main(int argc, char **argv) { if(print_info_opt) /* -i */ print_info(); - if(restore_term) /* -T */ + if(restore_term) /* -t */ fputs(ESC_UTF8_OFF, stdout); return 0; |