Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
Re: [Freeciv-Dev] patch: provide snprintf
Home

Re: [Freeciv-Dev] patch: provide snprintf

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] patch: provide snprintf
From: Greg Wooledge <wooledge@xxxxxxxxxxx>
Date: Sun, 30 May 1999 11:00:00 -0400

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/ |

[Prev in Thread] Current Thread [Next in Thread]