diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-10-20 15:22:21 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-10-20 15:22:21 +0200 |
commit | 1d8b9e17ea13630aec475484da09ebba0366f7c8 (patch) | |
tree | 0c801f68561bfb0930a4ade80d7ca3a7940887ab /tests/unistdio/test-u8-asnprintf1.h | |
parent | 84e26c587987e8484d55db4165f188b40c09e94b (diff) | |
parent | 630f99f29bd31a76d8d24da2975a045452c763ef (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/unistdio/test-u8-asnprintf1.h')
-rw-r--r-- | tests/unistdio/test-u8-asnprintf1.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unistdio/test-u8-asnprintf1.h b/tests/unistdio/test-u8-asnprintf1.h index f48e2365..7c2c3622 100644 --- a/tests/unistdio/test-u8-asnprintf1.h +++ b/tests/unistdio/test-u8-asnprintf1.h @@ -54,4 +54,59 @@ test_function (uint8_t * (*my_asnprintf) (uint8_t *, size_t *, const char *, ... if (result != buf) free (result); } + + /* Verify that u8_[v]asnprintf() rejects a width > 2 GiB, < 4 GiB. */ + { + size_t length; + uint8_t *s = my_asnprintf (NULL, &length, "x%03000000000dy\n", -17); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + static const uint8_t arg[] = { '@', 0 }; + size_t length; + uint8_t *s = my_asnprintf (NULL, &length, "x%03000000000Uy\n", arg); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + + /* Verify that u8_[v]asnprintf() rejects a width > 4 GiB. */ + { + size_t length; + uint8_t *s = + my_asnprintf (NULL, &length, + "x%04294967306dy\n", /* 2^32 + 10 */ + -17); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + static const uint8_t arg[] = { '@', 0 }; + size_t length; + uint8_t *s = + my_asnprintf (NULL, &length, + "x%04294967306Uy\n", /* 2^32 + 10 */ + arg); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + size_t length; + uint8_t *s = + my_asnprintf (NULL, &length, + "x%018446744073709551626dy\n", /* 2^64 + 10 */ + -17); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } + { + static const uint8_t arg[] = { '@', 0 }; + size_t length; + uint8_t *s = + my_asnprintf (NULL, &length, + "x%018446744073709551626Uy\n", /* 2^64 + 10 */ + arg); + ASSERT (s == NULL); + ASSERT (errno == EOVERFLOW); + } } |