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

Re: problem with GNU C



Ilya Teterin writes:
[someone else writes:]

>> The only thing I can think of (since you didn't indicate what the
>> differences were between the two boxes) is the first argument you
>> passed to select(). I'm pretty sure you'll never have 31000
>> descriptors open and I'm not even sure if the default fd_set can
>> hold that many, leading to your stack being trashed.
>> 
>> Other things: you should use snprintf, not sprintf and setting the
>> 100th byte to null is a waste of time.

    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).

> Setting byte to null was debug code. After all, what about my
> problem? ;) I see no difference between two boxes, except I
> wrote. Both installed from one CD set (official debian 2.2), kernel
> were not recompiled. Of course, there are some differences such as
> installed X, fetchmail and other packages, but I beleive that it
> isn't actual difference.

So what?  Bugs that don't show up everywhere are still bugs.

ttfn/rjk



Reply to: