[BusyBox] PATCH for crond EOL bug (Was: the bug system and 1.0.1)

Vladimir N. Oleynik dzo at simtreas.ru
Mon Jul 18 16:04:57 UTC 2005


Pauli Saksa wrote:
> On Fri, 15 Jul 2005 18:07:19 -0400 Paul Fox <pgf at brightstareng.com> wrote:
> 
> 
>>Not ready -- no proposed fix, or no patch, or link to patch broken. 
>>the fix may still be trivial, it just isn't available Right Now.
> 
> 
>>0000063 Other          minor   03-16-05 crond doesn't execute a crontab
>>entry with no trailing EOL
> 
> 
> For a reason I have already forgotten I never sent this patch forward...
> 
> Patched code ignores whitespace characters more effectively when
> reading crontab. Leading whitespace does not start a comment line
> anymore.
> 
> original:
> $ size miscutils/crond.o
>    text    data     bss     dec     hex filename
>    3949       8       8    3965     f7d miscutils/crond.o
> 
> patched:
> $ size miscutils/crond.o
>    text    data     bss     dec     hex filename
>    3917       8       8    3933     f5d miscutils/crond.o

I like this.

But

I examine libbb/trim.c and confused this:

         int len = strlen(s);

         /* trim trailing whitespace */
         while ( len > 0 && isspace(s[len-1]))
                 s[--len]='\0';

         /* trim leading whitespace */
         memmove(s, &s[strspn(s, " \n\r\t\v")], len);

man memmove
DESCRIPTION
        The  memmove() function copies n bytes from memory area src to memory area
        dest.  The memory areas may overlap.

I think, libbb/trim.c have momory overflow always if string arg have leading
whitespace.

May be

void trim(char *s)
{
         size_t len = strlen(s);
         size_t lws;

         /* trim trailing whitespace */
         while ( len > 0 && isspace(s[len-1]))
                 --len;

         /* trim leading whitespace */
         lws = strspn(s, " \n\r\t\v");
         len -= lws;
         memmove(s, s + lws, len);
         s[len] = 0;
}


is perfect?


--w
vodz



More information about the busybox mailing list