xref: /PHP-7.4/ext/gettext/tests/44938.phpt (revision d679f022)
1--TEST--
2#44938: gettext functions crash with overlong strings
3--SKIPIF--
4<?php
5if (!extension_loaded("gettext")) {
6	die("skip\n");
7}
8--FILE--
9<?php
10$overflown = str_repeat('C', 8476509);
11$msgid     = "msgid";
12$domain    = "domain";
13$category  = "cat";
14
15var_dump(bindtextdomain($overflown, 'path'));
16
17var_dump(dngettext($overflown, $msgid, $msgid, 1));
18var_dump(dngettext($domain, $overflown, $msgid, 1));
19var_dump(dngettext($domain, $msgid, $overflown, 1));
20
21var_dump(gettext($overflown));
22
23var_dump(ngettext($overflown, $msgid, -1));
24var_dump(ngettext($msgid, $overflown, -1));
25
26var_dump(dcgettext($overflown, $msgid, -1));
27var_dump(dcgettext($domain, $overflown, -1));
28
29var_dump(dcngettext($overflown, $msgid, $msgid, -1, -1));
30var_dump(dcngettext($domain, $overflown, $msgid, -1, -1));
31var_dump(dcngettext($domain, $msgid, $overflown, -1, -1));
32
33var_dump(dgettext($overflown, $msgid));
34var_dump(dgettext($domain, $overflown));
35
36var_dump(textdomain($overflown));
37?>
38==DONE==
39--EXPECTF--
40Warning: bindtextdomain(): domain passed too long in %s on line %d
41bool(false)
42
43Warning: dngettext(): domain passed too long in %s on line %d
44bool(false)
45
46Warning: dngettext(): msgid1 passed too long in %s on line %d
47bool(false)
48
49Warning: dngettext(): msgid2 passed too long in %s on line %d
50bool(false)
51
52Warning: gettext(): msgid passed too long in %s on line %d
53bool(false)
54
55Warning: ngettext(): msgid1 passed too long in %s on line %d
56bool(false)
57
58Warning: ngettext(): msgid2 passed too long in %s on line %d
59bool(false)
60
61Warning: dcgettext(): domain passed too long in %s on line %d
62bool(false)
63
64Warning: dcgettext(): msgid passed too long in %s on line %d
65bool(false)
66
67Warning: dcngettext(): domain passed too long in %s on line %d
68bool(false)
69
70Warning: dcngettext(): msgid1 passed too long in %s on line %d
71bool(false)
72
73Warning: dcngettext(): msgid2 passed too long in %s on line %d
74bool(false)
75
76Warning: dgettext(): domain passed too long in %s on line %d
77bool(false)
78
79Warning: dgettext(): msgid passed too long in %s on line %d
80bool(false)
81
82Warning: textdomain(): domain passed too long in %s on line %d
83bool(false)
84==DONE==
85