From: Ben H. <be...@de...> - 2010-04-09 00:13:29
|
On Thu, 2010-04-08 at 21:29 +1200, Lawrence D'Oliveiro wrote: > Ville Skyttä wrote: > > > There's now a similar warning from line 1698 in git: > > > > strncat(line2, directive, LINE_LEN); > > > > ...which I gather could overflow because length of both line2 and directive is > > LINE_LEN and from my strncat man page: > > > > If src contains n or more characters, strncat() writes n+1 characters > > to dest (n from src plus the terminating null byte). Therefore, the > > size of dest must be at least strlen(dest)+n+1. > > A pox on null-terminated strings. Damn them, I say. Verily, let them be > thrice-cursed. Is there no simple function I can use to append to one so > it won’t overflow a fixed limit? snprintf() is slight overkill but will do the job. Ben. -- Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse. |