On Fri, Jan 10, 2003 at 12:10:37PM -0600, Ronald Fenner wrote: > sprintf(temp, "\r\n &c%s list&n\r\n", guild_types[i]); > strcat(buf, temp); The method I've been using is: len += snprintf(buf + len, sizeof(buf) - len, "\r\n &c%s list&n\r\n", guild_types[i]); Which will ensure that you never overflow buf so long as you always keep len == sizeof(buf), might not even be a bad idea to assert() that if there are general-use functions doing this that you're afraid your developers might misuse. A friend of mine even suggested making a struct, maybe called checked_string, that associates an int for "len" with a fixed-size string. -- { IRL(Jeremy_Stanley); PGP(9E8DFF2E4F5995F8FEADDC5829ABF7441FB84657); SMTP(fungi@yuggoth.org); IRC(fungi@irc.yuggoth.org#ccl); ICQ(114362511); AIM(dreadazathoth); YAHOO(crawlingchaoslabs); FINGER(fungi@yuggoth.org); MUD(Nergel@srmud.net:2325); WWW(http://fungi.yuggoth.org/); } -- +---------------------------------------------------------------+ | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html | | Newbie List: http://groups.yahoo.com/group/circle-newbies/ | +---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/26/03 PDT