diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-03-22 18:00:25 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-03-22 18:00:25 +0100 |
commit | 0737819efdd0bae112d16d874cac7e747e43cd08 (patch) | |
tree | 98a9ac84f7f347ae530c14852c68870682f3d04c /tests/unistdio/test-u16-asnprintf1.h | |
parent | 163a663518f33bab48b28431972e580b366b4d49 (diff) | |
parent | e670957a8693f860cf7d77fed4ce6b4b056a8083 (diff) |
Merge branch 'release/debian/1.3-1'debian/1.3-1
Diffstat (limited to 'tests/unistdio/test-u16-asnprintf1.h')
-rw-r--r-- | tests/unistdio/test-u16-asnprintf1.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unistdio/test-u16-asnprintf1.h b/tests/unistdio/test-u16-asnprintf1.h index 4ec31a43..2b1a9ab3 100644 --- a/tests/unistdio/test-u16-asnprintf1.h +++ b/tests/unistdio/test-u16-asnprintf1.h @@ -57,4 +57,59 @@ test_function (uint16_t * (*my_asnprintf) (uint16_t *, size_t *, const char *, . if (result != buf) free (result); } + + /* Verify that u16_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */ + { + size_t length; + uint16_t *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + static const uint16_t arg[] = { '@', 0 }; + size_t length; + uint16_t *s = my_asnprintf (NULL, &length, "x%03000000000lUy\n", arg); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + + /* Verify that u16_[v]asnprintf() rejects a width > 4 GiB. */ + { + size_t length; + uint16_t *s = + my_asnprintf (NULL, &length, + "x%04294967306dy\n", /* 2^32 + 10 */ + -17); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + static const uint16_t arg[] = { '@', 0 }; + size_t length; + uint16_t *s = + my_asnprintf (NULL, &length, + "x%04294967306lUy\n", /* 2^32 + 10 */ + arg); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + size_t length; + uint16_t *s = + my_asnprintf (NULL, &length, + "x%018446744073709551626dy\n", /* 2^64 + 10 */ + -17); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + static const uint16_t arg[] = { '@', 0 }; + size_t length; + uint16_t *s = + my_asnprintf (NULL, &length, + "x%018446744073709551626lUy\n", /* 2^64 + 10 */ + arg); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } } |