posix_uname another bug @^|[@#\@^#~@{[?

From: Date: Sun, 24 Mar 2002 11:03:42 +0000
Subject: posix_uname another bug @^|[@#\@^#~@{[?
Groups: php.qa 
Request: Send a blank email to php-qa+get-4673@lists.php.net to get a copy of this message
refere include file : sys/utsname.h ! You can see if the macro __USE_GNU is set the char returned are 'domainname' else the char are '__domainname' #@\[@~\ You know this function can do a apache segfault ?! Becarful cuz domainename doesn't exist on freebsd ! there is the current (PHP-4.2.0RC1) code on : ext/posix/posix.c /* {{{ proto array posix_uname(void) Get system name (POSIX.1, 4.4.1) */ PHP_FUNCTION(posix_uname) { struct utsname u; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE)
       return;
if (uname(&u) < 0) {
       POSIX_G(last_error) = errno;
       RETURN_FALSE;
} if (array_init(return_value) == FAILURE) {
       // TODO: Should we issue a warning here so we don't have ambiguity
       // with the above return value ?
       RETURN_FALSE;
} add_assoc_string(return_value, "sysname", u.sysname, 1); add_assoc_string(return_value, "nodename", u.nodename, 1); add_assoc_string(return_value, "release", u.release, 1); add_assoc_string(return_value, "version", u.version, 1); add_assoc_string(return_value, "machine", u.machine, 1);
#ifdef _GNU_SOURCE    /* i'm okay */
   add_assoc_string(return_value, "domainname", u.domainname, 1); /* <- {|^@#\|^[#\ */
#endif } /* }}} */ /*--------------------------------------------------------Fixed code--------------------------------------------------*/ /* {{{ proto array posix_uname(void) Get system name (POSIX.1, 4.4.1) */ PHP_FUNCTION(posix_uname) { struct utsname u; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE)
       return;
if (uname(&u) < 0) {
       POSIX_G(last_error) = errno;
       RETURN_FALSE;
} if (array_init(return_value) == FAILURE) {
       // TODO: Should we issue a warning here so we don't have ambiguity
       // with the above return value ?
       RETURN_FALSE;
} add_assoc_string(return_value, "sysname", u.sysname, 1); add_assoc_string(return_value, "nodename", u.nodename, 1); add_assoc_string(return_value, "release", u.release, 1); add_assoc_string(return_value, "version", u.version, 1); add_assoc_string(return_value, "machine", u.machine, 1); #ifdef _GNU_SOURCE #ifdef __USE_GNU
       add_assoc_string(return_value, "domainname", u.domainname, 1);
#else
       add_assoc_string(return_value, "domainname", u.__domainname, 1);
#endif #endif } /* }}} */

« previous php.qa (#4673) next »