home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.unix.geeks      The gathering of the socially-retarded      298 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 231 of 298   
   rbowman to Richard Kettlewell   
   Re: What is wrong with C? (and fond memo   
   07 Jan 26 01:40:29   
   
   XPost: comp.os.linux.misc, alt.folklore.computers   
   From: bowman@montana.com   
      
   On Tue, 06 Jan 2026 22:54:26 +0000, Richard Kettlewell wrote:   
      
   > scott@slp53.sl.home (Scott Lurndal) writes:   
   >> rbowman  writes:   
   >>>On Tue, 06 Jan 2026 18:57:04 GMT, Charlie Gibbs wrote:   
   >>>> Inspired by readline(), I've written my own replacements for strcpy()   
   >>>> and strcat() that do much the same thing.   
   >>>   
   >>>To quote from the strcat man page "Read about Shlemiel the painter.".   
   >>>stpcpy() was a late arrival and I never used it. I do use a similar   
   >>>construct   
   >>>   
   >>>char buf[1024];   
   >>>char* ptr = buf;   
   >>>   
   >>>ptr += sprintf(ptr, "%s", "some stuff");   
   >>>ptr += sprintf(ptr, "%s", " some more stuff");   
   >>   
   >> I would suggest using snprintf instead of sprintf to prevent accesses   
   >> beyond (buf + 1024).  A bit more complicated if you want to know that   
   >> the result was truncated, since you need to adjust the remaining length   
   >> based on the return value from the prior snprintf, as well as checking   
   >> for overflow.   
   >   
   > This is calling out for a wrapping up in a function or two that can do   
   > the book-keeping automatically (and use an expandable buffer, if the use   
   > case demands).   
      
      
      
   Ah, mission creep...   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca