cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: 回复: Re: Patch to make curl support file://upload/ resume

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 30 May 2007 10:39:18 -0700

On Wed, May 30, 2007 at 03:15:29PM +0800, 峰 涂 wrote:
> hi, I have adjusted my patch as your requirements.

I've noticed another couple of things:

> + if(stat(file->path, &file_stat)){
> + failf(data, "Can't get the size of %s", file->path);
> + return CURLE_WRITE_ERROR;

If this error path is taken, it will leak a file descriptor.

> + if(data->reqdata.resume_from){
> + if( nread <= data->reqdata.resume_from ){
> + data->reqdata.resume_from -= nread;
> + nread = 0;

If this condition is true, then the call to fwrite below will pass in an
uninitialized buf2 variable on the first pass.

> + }
> + else{
> + buf2 = buf + data->reqdata.resume_from;
> + nread -= data->reqdata.resume_from;
> + data->reqdata.resume_from = 0;
> + }
> + }
> + else
> + buf2 = buf;
> +
> /* write the data to the target */
> - nwrite = fwrite(buf, 1, nread, fp);
> + nwrite = fwrite(buf2, 1, nread, fp);
> if(nwrite != nread) {
> res = CURLE_SEND_ERROR;
> break;

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-05-30