Re: [Freeciv-Dev] patch: provide snprintf
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
David Pfitzner (dwp@xxxxxxxxxxxxxx) wrote:
> + if (sigsetjmp(bail, 1) == 0) {
> + if (sigaction(SIGSEGV, &nsa, &osa) == -1) {
> + mcleanup(str, n, p);
> + return (0);
> + }
> + ret = vsprintf(p, fmt, ap);
> + }
> + mcleanup(str, n, p);
> + (void) sigaction(SIGSEGV, &osa, NULL);
> + return (ret);
If I'm reading this right, it allocates a region of memory and uses
mprotect(2) to cause the program to get a SIGSEGV if it writes outside
this version. Then it writes chars to this region using the standard
vsprintf(3).
Does this work on all Unix systems? I would imagine that there may be
a few without sigaction(2) or mprotect(2) (or both).
I don't have a clue what this would do under Win32, OS/2, AmigaOS, etc.
--
Greg Wooledge | Distributed.NET http://www.distributed.net/
wooledge@xxxxxxxxxxx | because a CPU is a terrible thing to waste.
http://www.kellnet.com/wooledge/ |
|
|