xref: /PHP-5.4/ext/gettext/tests/44938.phpt (revision b51214fc)
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--
40
41Warning: bindtextdomain(): domain passed too long in %s on line %d
42bool(false)
43
44Warning: dngettext(): domain passed too long in %s on line %d
45bool(false)
46
47Warning: dngettext(): msgid1 passed too long in %s on line %d
48bool(false)
49
50Warning: dngettext(): msgid2 passed too long in %s on line %d
51bool(false)
52
53Warning: gettext(): msgid passed too long in %s on line %d
54bool(false)
55
56Warning: ngettext(): msgid1 passed too long in %s on line %d
57bool(false)
58
59Warning: ngettext(): msgid2 passed too long in %s on line %d
60bool(false)
61
62Warning: dcgettext(): domain passed too long in %s on line %d
63bool(false)
64
65Warning: dcgettext(): msgid passed too long in %s on line %d
66bool(false)
67
68Warning: dcngettext(): domain passed too long in %s on line %d
69bool(false)
70
71Warning: dcngettext(): msgid1 passed too long in %s on line %d
72bool(false)
73
74Warning: dcngettext(): msgid2 passed too long in %s on line %d
75bool(false)
76
77Warning: dgettext(): domain passed too long in %s on line %d
78bool(false)
79
80Warning: dgettext(): msgid passed too long in %s on line %d
81bool(false)
82
83Warning: textdomain(): domain passed too long in %s on line %d
84bool(false)
85==DONE==
86