Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#170 closed defect (fixed)

SafeDosStartSession only passed first environment variable to child

Reported by: guest Owned by: bird
Priority: normal Milestone: libc-0.6.3
Component: libc Version: 0.6
Severity: normal Keywords:
Cc: mozilla@…

Description

Using libc062 and the highmem safe version (via #include <os2safe.h>) of DosStartSession? only the very first environment variable is passed to the child. I will attach a test program that is broken when compiled with

gcc -Zhigh-mem -Zomf -Zexe DSS_test.c

The shell that is opened only contains

[C:\] set WP_OBJHANDLE=164325 PATH= COMSPEC=C:\OS2\CMD.EXE

in the environment.

I believe that this is in part due to the use of str*() functions to work with the STARTDATA.Environment object that consists of many \0 separated strings. Specifically, this

l4 = strlen((const char *)Environment) + 1;

would better be written like this

char *p = Environment; while (*p) {

p += strlen(p) + 1;

} l4 = (int)(p - Environment);

Attachments (1)

DSS_test.c (1.4 KB) - added by guest 17 years ago.
test program

Download all attachments as: .zip

Change History (4)

Changed 17 years ago by guest

Attachment: DSS_test.c added

test program

comment:1 Changed 17 years ago by guest

Actually, the "patch" should rather be

    char *p = Environment;
    while (*p) {
        p += strlen(p) + 1;
    } l4 = (int)(p - Environment) + 1;

including the final +1 to count the last '\0', too.

comment:2 Changed 17 years ago by bird

Resolution: fixed
Status: newclosed

(In [3384]) Count the whole environment. Fixes #170. pulIdSession and ppid can be NULL, don't crash if they are and pass the correct values to DosStartSession?. Fixes #169.

comment:3 Changed 17 years ago by bird

Component: baselayoutlibc
Milestone: libc-0.6.3
Version: 0.6
Note: See TracTickets for help on using tickets.