[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: problem with GNU C



>     if(strlen(str)>1024)
>         return -1;
>
>     strcpy(stuff,str);
>
> This should be "if(strlen(str) >= 1024)".  You've forgotten to account
> for the 0 byte.  There are similar problems elsewhere.
> It would be better to use "sizeof stuff" instead of 1024 (since stuff
> is an array in this case) and even better to avoid a fixed limit on
> string size altogether (there are useful URLs out there longer than
> 1023 characters).
Thanks again ;) But it isn't a competition "found as much bugs as
possible"... No one of described bugs can be a reason for such strange
behaviour. Are you really believe that program crashed because the length of
one string was equal (not less and not greater) than 1024? Additionally, I
believe that even if it occurs, it will not crash the program...




Reply to: