aboutsummaryrefslogtreecommitdiff
path: root/uxd.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-23 21:58:47 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-23 21:58:47 -0500
commit06bcc5b5773b744994abda1424369df24e332e2c (patch)
treee9da482051bfa6060194423fd359af11b37e50a4 /uxd.c
parent8a34d1a58b9f750ead06190a33c43385c829e428 (diff)
downloaduxd-06bcc5b5773b744994abda1424369df24e332e2c.tar.gz
do not dump past end of -d argument
Diffstat (limited to 'uxd.c')
-rw-r--r--uxd.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/uxd.c b/uxd.c
index 35dd2aa..9094047 100644
--- a/uxd.c
+++ b/uxd.c
@@ -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;