Skip to content

add SensitiveParameter as known string and use it in arginfo #8991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Zend/zend_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ EMPTY_SWITCH_DEFAULT_CASE()
_(ZEND_STR_AUTOGLOBAL_ENV, "_ENV") \
_(ZEND_STR_AUTOGLOBAL_REQUEST, "_REQUEST") \
_(ZEND_STR_COUNT, "count") \
_(ZEND_STR_SENSITIVEPARAMETER, "SensitiveParameter") \


typedef enum _zend_known_string_id {
Expand Down
14 changes: 11 additions & 3 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2373,11 +2373,19 @@ public function __construct(string $class, array $args) {

/** @param iterable<ConstInfo> $allConstInfos */
public function generateCode(string $invocation, string $nameSuffix, iterable $allConstInfos): string {
/* see ZEND_KNOWN_STRINGS in Zend/strings.h */
static $knowns = [
"SensitiveParameter" => "ZEND_STR_SENSITIVEPARAMETER",
];
$code = "\n";
$escapedAttributeName = strtr($this->class, '\\', '_');
$code .= "\tzend_string *attribute_name_{$escapedAttributeName}_$nameSuffix = zend_string_init(\"" . addcslashes($this->class, "\\") . "\", sizeof(\"" . addcslashes($this->class, "\\") . "\") - 1, 1);\n";
$code .= "\t" . ($this->args ? "zend_attribute *attribute_{$escapedAttributeName}_$nameSuffix = " : "") . "$invocation, attribute_name_{$escapedAttributeName}_$nameSuffix, " . count($this->args) . ");\n";
$code .= "\tzend_string_release(attribute_name_{$escapedAttributeName}_$nameSuffix);\n";
if (isset($knowns[$escapedAttributeName])) {
Copy link
Member

@kocsismate kocsismate Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, I tried to use a similar approach in case of known strings when I started to work on generating properties, but then Nikita asked me to simply ignore them and only use normal strings. My guess is that we don't really need to deal with known strings if the string in question is allocated as permanent (?).

That's why I think it would be more future-proof to just collect all the different attribute names and declare them at once. As this would be slightly more difficult to implement, let's go with your known-string based approach for beta 1.

$code .= "\t" . ($this->args ? "zend_attribute *attribute_{$escapedAttributeName}_$nameSuffix = " : "") . "$invocation, ZSTR_KNOWN({$knowns[$escapedAttributeName]}), " . count($this->args) . ");\n";
} else {
$code .= "\tzend_string *attribute_name_{$escapedAttributeName}_$nameSuffix = zend_string_init(\"" . addcslashes($this->class, "\\") . "\", sizeof(\"" . addcslashes($this->class, "\\") . "\") - 1, 1);\n";
$code .= "\t" . ($this->args ? "zend_attribute *attribute_{$escapedAttributeName}_$nameSuffix = " : "") . "$invocation, attribute_name_{$escapedAttributeName}_$nameSuffix, " . count($this->args) . ");\n";
$code .= "\tzend_string_release(attribute_name_{$escapedAttributeName}_$nameSuffix);\n";
}
foreach ($this->args as $i => $arg) {
$value = EvaluatedValue::createFromExpression($arg->value, null, null, $allConstInfos);
$zvalName = "attribute_{$escapedAttributeName}_{$nameSuffix}_arg$i";
Expand Down
4 changes: 1 addition & 3 deletions ext/ftp/ftp_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 7 additions & 21 deletions ext/hash/hash_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions ext/imap/php_imap_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions ext/ldap/ldap_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 7 additions & 21 deletions ext/mysqli/mysqli_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions ext/oci8/oci8_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading