siva-msft / php-src

Other
0 stars 1 forks source link

Potential issue in ext/standard/mail.c: Unchecked return from initialization function #12

Open monocle-ai opened 4 years ago

monocle-ai commented 4 years ago

What is a Conditionally Uninitialized Variable? The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in undefined behavior.

1 instance of this defect were found in the following locations:


Instance 1 File : ext/standard/mail.c Enclosing Function : php_mail Function : zend_spprintf https://github.com/siva-msft/php-src/blob/22982eee339c4983c87cea5d59aaf48601ad7030/ext/standard/mail.c#L452 Issue in: logline

Code extract:

    if (mail_log && *mail_log) {
        char *logline;

        spprintf(&logline, 0, "mail() on [%s:%d]: To: %s -- Headers: %s -- Subject: %s", zend_get_executed_filename(), zend_get_executed_lineno(), to, hdr ? hdr : "", subject); <------ HERE

        if (hdr) {

How can I fix it? Correct reference usage found in ext/standard/var.c at line 579. https://github.com/siva-msft/php-src/blob/22982eee339c4983c87cea5d59aaf48601ad7030/ext/standard/var.c#L579 Code extract:

                zend_release_properties(myht);
            }
            if (level > 1) {
                buffer_append_spaces(buf, level - 1); <------ HERE
            }
            if (Z_OBJCE_P(struc) == zend_standard_class_def) {
siva-msft commented 4 years ago

bogus