aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-12-19 19:52:19 +0100
committerJay Berkenbilt <ejb@ql.org>2021-12-19 20:30:45 +0100
commitea73bf72e0ff2577672eec405380456fa56bc6af (patch)
tree60de3d8de4d03a99a3391a4e286eb7893eb20408 /qpdf
parent92613a1eec543a00dd25dc6cdd407929323a811c (diff)
downloadqpdf-ea73bf72e0ff2577672eec405380456fa56bc6af.tar.zst
Further improvements to handling binary strings
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qpdf-ctest.c11
-rw-r--r--qpdf/qpdf.testcov2
2 files changed, 12 insertions, 1 deletions
diff --git a/qpdf/qpdf-ctest.c b/qpdf/qpdf-ctest.c
index dbad4e99..953b24d0 100644
--- a/qpdf/qpdf-ctest.c
+++ b/qpdf/qpdf-ctest.c
@@ -781,8 +781,17 @@ static void test27(char const* infile,
assert(strcmp(qpdf_oh_get_string_value(qpdf, p_string_with_null),
"one") == 0);
assert(qpdf_get_last_string_length(qpdf) == 7);
+ /* memcmp adds a character to verify the trailing null */
assert(memcmp(qpdf_oh_get_string_value(qpdf, p_string_with_null),
- "one\000two", 7) == 0);
+ "one\000two", 8) == 0);
+ size_t length = 0;
+ p_string_with_null = qpdf_oh_new_binary_string(qpdf, "potato\000salad", 12);
+ /* memcmp adds a character to verify the trailing null */
+ assert(memcmp(qpdf_oh_get_binary_string_value(
+ qpdf, p_string_with_null, &length),
+ "potato\000salad", 13) == 0);
+ assert(qpdf_get_last_string_length(qpdf) == 12);
+ assert(length == 12);
}
static void test28(char const* infile,
diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov
index 034f8d8e..35417d4c 100644
--- a/qpdf/qpdf.testcov
+++ b/qpdf/qpdf.testcov
@@ -625,3 +625,5 @@ qpdf-c stream data buf set 1
qpdf-c called qpdf_oh_get_page_content_data 0
qpdf-c called qpdf_oh_replace_stream_data 0
qpdf-c silence oh errors 0
+qpdf-c called qpdf_oh_get_binary_string_value 0
+qpdf-c called qpdf_oh_new_binary_string 0