bug-wget
[Top][All Lists]
Advanced

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

Re: [Bug-wget] Wget 1.11.4 and FTP Server from Windows Server 2008 R2


From: Ray Satiro
Subject: Re: [Bug-wget] Wget 1.11.4 and FTP Server from Windows Server 2008 R2
Date: Fri, 5 Oct 2012 14:11:41 -0700 (PDT)

----- Original Message -----

> From: Tim Ruehsen <address@hidden>
> To: address@hidden; Ray Satiro <address@hidden>
> Cc: 
> Sent: Friday, October 5, 2012 5:29 AM
> Subject: Re: [Bug-wget] Wget 1.11.4 and FTP Server from Windows Server 2008 R2
> 
> I am not willing to look too deeply into this bloated code in url.c.
> 
> But from a peephole point of view, what do you think of a codechange like 
> this:
> 
>   max_length = get_max_length (fnres.base, fnres.tail, _PC_NAME_MAX);
> 
>   if (max_length > CHOMP_BUFFER)
>     max_length -= CHOMP_BUFFER;
>   else
>     max_length = 0;
> 
>   if (max_length > 0 && strlen (temp_fnres.base) > max_length)
>     {
>       logprintf (LOG_NOTQUIET, "The name is too long, %lu chars 
> total.\n",
>           (unsigned long) strlen (temp_fnres.base));
>       logprintf (LOG_NOTQUIET, "Trying to shorten...\n");
> 
>       /* Shorten the file name. */
>       temp_fnres.base[max_length] = '\0';
>       temp_fnres.tail = max_length;
> 
>       logprintf (LOG_NOTQUIET, "New name is %s.\n", 
> temp_fnres.base);
>     }

The first problem is fixed. The second problem is fixed technically but writing 
to the string object's members I think is not preferable. What is needed is 
more supporting functions for the string object, and it should either be always 
null terminated or never, not sometimes.

Attached is a patch relative to commit e9845d2. I propose that base should 
always be null terminated. tail represents the length of the string and does 
not include the terminating null. Any function directly writing to the members 
of a growable string object must call append_null(). Functions that already do 
this I've changed to call append_null(): shorten_length(), append_char(), 
append_string(), append_uri_pathel().

shorten_length() is new. I would ditch the strlen calls and use .tail because 
.tail is now the length

if( max_length > 0 && temp_fnres.tail > max_length )
{
[...]
shorten_length(max_length, &temp_fnres);
[...]
}

also what is meant to happen if max_length is 0

Attachment: url.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]