Just to add to the discussion,

Code:
grp = new char [sizeof (penv) + 1];
makes me think you really want to do:

Code:
grp = new char [strlen(penv) + 1];
since unless I'm crazy, sizeof(penv) is always 4 (a.k.a. the size of a pointer on a 32-bit system). I could be wrong, though...

Regards,
Bassman