Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Writing to argv[0]
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-10-10 (20:11)
From: Dave Benjamin <dave@r...>
Subject: Re: [Caml-list] Writing to argv[0]
On Fri, 10 Oct 2008, Jason Noakes wrote:

> Just be careful with that. You are copying over memory and you also 
> aren't doing any bounds checking. A long enough "Proctitle.setproctitle" 
> argument will corrupt your process.

Good point. Even a moderately long argument will corrupt the environment:

# Proctitle.setproctitle "Mary had a little lamb, whose fleece was white 
as snow.";;
- : unit = ()
# Unix.environment ();;
- : string array =
[|"little lamb, whose fleece was white as snow.";
   ", whose fleece was white as snow."; " was white as snow."; "w.";

That is why you not only need bounds checking but relocation of the 
environment to do this safely.