Re: [NEWBIE] Limits of stuff

From: John Evans (evansj@HI-LINE.NET)
Date: 03/04/98


On Wed, 4 Mar 1998, Chuck Reed wrote:

> And today my inexperience shines . . .
>
> Anyhow,  I'm hunting for a memory overflow as some may already know, and
> was wondering exactly how much a char *somthing could hold.  I'm mainly
> concerned with my prompt code being the problem, and I don't know how to
> check these character pointer thingy-ma-bobs (the coder definition right
> there).
>

When I installed Danial Koepke's nifty prompt code, I ended up with the
code overflowing the max. prompt length string and crashing the mud. The
color codes are only two letters in length (&R for example), but
translate into ~9 characters (&R turns into \x1B[0;31m). If you have 10
to 20 color changes in a prompt this can EASILY screw things up.

My fix (which was probably the hardest) was to scan through the new prompt
that the player had submitted and count color codes as 9 characters
instead of 2. If their prompt would end up larger than MAX_PROMPT_LENGTH
(512 on my mud), then I rejected the prompt and told them why. If the
prompt was short enough, then it was accepted. I did the same for the
other codes, but I translated most of them (%h for example) into three
characters long, instead of nine.

I hope my rambling helped some.

John Evans <evansj@hi-line.net>  --  http://www.hi-line.net/~evansj/

Any sufficiently advanced technology is indistinguishable from magic.
--Arthur C. Clarke


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST