I already changed it to use Dan's suggested strlcat() loop.
On Fri, Nov 13, 2015 at 9:21 AM, barret rhoden <[email protected]> wrote: > On 2015-11-13 at 9:03 'Davide Libenzi' via Akaros wrote: > > On Fri, Nov 13, 2015 at 8:32 AM, barret rhoden <[email protected]> > > wrote: > > > > > > + for (i = 0; cmds[i]; i++) { > > > >> > + csize = strlen(cmds[i]); > > > >> > + if ((csize + size + 2) > sizeof(msgbuf)) > > > >> > + break; > > > >> > + msgbuf[size] = '|'; > > > >> > + memcpy(msgbuf + size + 1, cmds[i], csize); > > > >> > + size += csize + 1; > > > >> > + } > > > >> > + msgbuf[size] = 0; > > > > > > this has a lot of "+2" and +1. hope we don't have an off-by-one > > > error! or forget the trailing msgbuf[size] = 0; > > > > > > > I'm confused. You say there is a bug in that code? Where is it? > > No, I'm saying that it is harder to write and be sure that code is > correct compared to the strlcat code. It's more of a defense of using > the simpler but slower code for the sake of maintainability/auditing. > > But no need to change your existing code, and I didn't spot anything > wrong with it when I looked at it the first time. > > Barret > > -- > You received this message because you are subscribed to the Google Groups > "Akaros" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
