# SID was accidently changed to CONST_CS?

- Thread: https://externals.io/message/16344
- Original archive: https://news-web.php.net/php.internals/16344
- Started by Jani Taskinen on 2005-05-31T08:04:20+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #16344 — Jani Taskinen — 2005-05-31T08:04:20+00:00

URL: https://externals.io/message/16344#16344

Regarding this bug: http://bugs.php.net/bug.php?id=29322&edit=1

     And by looking at this commit by Andi:

       http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.391&r2=1.392&ty=u

     and this part of it:

-		REGISTER_STRINGL_CONSTANT("SID", empty_string, 0, 0);
+		REGISTER_STRINGL_CONSTANT("SID", "", 0, 1);

     Where flags changed from 0 to 1..
     Intentional or not?

     --Jani

---

## #16345 — Andi Gutmans — 2005-05-31T14:27:28+00:00

URL: https://externals.io/message/16344#16345 · In reply to: #16344

Yes, the flag change was intentional in order to create an allocated empty 
string.
I doubt this has anything to do with the bug report though.

At 11:04 AM 5/31/2005 +0300, Jani Taskinen wrote:

>     Regarding this bug: http://bugs.php.net/bug.php?id=29322&edit=1
>
>     And by looking at this commit by Andi:
>
> 
>http://cvs.php.net/diff.php/php-src/ext/session/session.c?r1=1.391&r2=1.392&ty=u
>
>     and this part of it:
>
>-               REGISTER_STRINGL_CONSTANT("SID", empty_string, 0, 0);
>+               REGISTER_STRINGL_CONSTANT("SID", "", 0, 1);
>
>     Where flags changed from 0 to 1..
>     Intentional or not?
>
>     --Jani

---

## #16349 — Sara Golemon — 2005-05-31T17:48:51+00:00

URL: https://externals.io/message/16344#16349 · In reply to: #16345

> > […]
> Yes, the flag change was intentional in order to create an allocated empty
> string.
>
The fourth parameter to REGISTER_STRINGL_CONSTANT is supposed to be flags
(e.g. CONST_CS, CONST_PERSIST) not a copy indicator.

The underlying implementation of zend_register_stringl_constant() never
copies value:

#define REGISTER_STRINGL_CONSTANT(name, str, len, flags)
zend_register_stringl_constant((name), sizeof(name), (str), (len), (flags),
module_number TSRMLS_CC)

ZEND_API void zend_register_stringl_constant(char *name, uint name_len, char
*strval, uint strlen, int flags, int module_number TSRMLS_DC)
{
    zend_constant c;

    c.value.type = IS_STRING;
    c.value.value.str.val = strval;
    c.value.value.str.len = strlen;
    c.flags = flags;
    c.name = zend_strndup(name, name_len-1);
    c.name_len = name_len;
    c.module_number = module_number;
    zend_register_constant(&c TSRMLS_CC);
}

By setting flags to 1 (the value of CONST_CS), the zend_register_constant()
function uses the unmodified "SID" as the constant name, rather than the
 `strtolower()`'d "sid" which is what `session_regenerate_id()` attempts to
destroy.

-Sara

---

## #16350 — Andi Gutmans — 2005-05-31T19:36:18+00:00

URL: https://externals.io/message/16344#16350 · In reply to: #16344

Jani,

The flag chance was not intentional. I think I made that change as part of 
a change to nuke empty_string() and that change to 1 was supposed to tell 
REGISTER_STRINGL_CONSTANT to dup the string. My mistake and I think it 
should be reverted. I confused it with the RETURN_* macros.

Andi

At 07:27 AM 5/31/2005 -0700, Andi Gutmans wrote:
>Yes, the flag change was intentional in order to create an allocated empty 
>string.
>I doubt this has anything to do with the bug report though.
>
>At 11:04 AM 5/31/2005 +0300, Jani Taskinen wrote:
>
> > […]
