Browse Source

Fix error handling

Offset overflowed.
Přemysl Janouch 2 years ago
parent
commit
29062e6c44
Signed by: Přemysl Janouch <p.janouch@gmail.com> GPG Key ID: B715679E3A361BE6
1 changed files with 6 additions and 6 deletions
  1. 6
    6
      bfc-amd64.c

+ 6
- 6
bfc-amd64.c View File

@@ -619,9 +619,9 @@ main (int argc, char *argv[])
619 619
 	CODE ("\x66\x5B")            // pop bx
620 620
 
621 621
 	CODE ("\x48\x83\xF8\x00")    // cmp rax, 0
622
-	CODE ("\x48\x8D\x35") DD (4) // lea rsi, [rel read_message]
623
-	CODE ("\x7C")                // jl "fatal_offset" -- write failure message
624
-	DB ((intptr_t) fatal_offset - (intptr_t) (buffer.len + 1))
622
+	CODE ("\x48\x8D\x35") DD (8) // lea rsi, [rel read_message]
623
+	CODE ("\x0F\x8C")            // jl "fatal_offset" -- write failure message
624
+	DD ((intptr_t) fatal_offset - (intptr_t) (buffer.len + 4))
625 625
 	CODE ("\x58")                // pop rax -- restore tape position
626 626
 	CODE ("\xC3")                // ret
627 627
 	CODE ("fatal: read failed\n\0")
@@ -637,9 +637,9 @@ main (int argc, char *argv[])
637 637
 	CODE ("\x66\x5B")            // pop bx
638 638
 
639 639
 	CODE ("\x48\x83\xF8\x00")    // cmp rax, 0
640
-	CODE ("\x48\x8D\x35") DD (4) // lea rsi, [rel write_message]
641
-	CODE ("\x7C")                // jl "fatal_offset" -- write failure message
642
-	DB ((intptr_t) fatal_offset - (intptr_t) (buffer.len + 1))
640
+	CODE ("\x48\x8D\x35") DD (8) // lea rsi, [rel write_message]
641
+	CODE ("\x0F\x8C")            // jl "fatal_offset" -- write failure message
642
+	DD ((intptr_t) fatal_offset - (intptr_t) (buffer.len + 4))
643 643
 	CODE ("\x58")                // pop rax -- restore tape position
644 644
 	CODE ("\xC3")                // ret
645 645
 	CODE ("fatal: write failed\n\0")

Loading…
Cancel
Save