bug in using putenv()

16 views
Skip to first unread message

Sergey Pinaev

unread,
Feb 27, 2015, 6:12:38 AM2/27/15
to racke...@googlegroups.com
hi.
sch_unix_putenv does:

oldbuffer = (char *)putenv_str_table_get(var);
if (oldbuffer)
      free(oldbuffer);
putenv_str_table_put_name(var, buffer);
putenv(buffer);

this is wrong. free(oldbuffer) should be called AFTER putenv(buffer), because
putenv_str_table_put_name() can call malloc and get memory used by oldbuffer
and overwrite its content. but environment, modified by putenv, is list of pointers
to strings (in "key=value" form) and it contains pointer to oldbuffer.

Matthew Flatt

unread,
Feb 27, 2015, 10:00:48 AM2/27/15
to Sergey Pinaev, racke...@googlegroups.com
Thanks! I'll push a repair.
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-dev+...@googlegroups.com.
> To post to this group, send email to racke...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-dev/f76d8cee-0a8c-4a1f-93c7-085bbb6cea
> 63%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages