From 8fc601cb97236f7f0a14e74f3fedba352d776d30 Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Sat, 22 Nov 2025 11:08:45 -0500 Subject: [PATCH] escape carriage return and double quote characters otherwise we can get invalid liftings for strings containing those characters. --- CodeHawk/CHB/bchlibelf/bCHELFSection.ml | 2 ++ CodeHawk/CHB/bchlibelf/bCHELFSegment.ml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CodeHawk/CHB/bchlibelf/bCHELFSection.ml b/CodeHawk/CHB/bchlibelf/bCHELFSection.ml index dfad7a6e..b7ee2835 100644 --- a/CodeHawk/CHB/bchlibelf/bCHELFSection.ml +++ b/CodeHawk/CHB/bchlibelf/bCHELFSection.ml @@ -119,6 +119,8 @@ object (self) if Char.code s.[offset + len] = 0 then let str = String.sub s offset len in let new_s = string_replace '\n' "\\n" str in + let new_s = string_replace '\r' "\\r" new_s in + let new_s = string_replace '"' "\\\"" new_s in begin string_table#add_string va new_s; Some new_s diff --git a/CodeHawk/CHB/bchlibelf/bCHELFSegment.ml b/CodeHawk/CHB/bchlibelf/bCHELFSegment.ml index 677ef1e7..c7eefad8 100644 --- a/CodeHawk/CHB/bchlibelf/bCHELFSegment.ml +++ b/CodeHawk/CHB/bchlibelf/bCHELFSegment.ml @@ -87,6 +87,8 @@ object (self) if Char.code s.[offset+len] = 0 then let str = String.sub s offset len in let new_s = string_replace '\n' "\\n" str in + let new_s = string_replace '\r' "\\r" new_s in + let new_s = string_replace '"' "\\\"" new_s in begin string_table#add_string va new_s ; Some new_s