cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: strippath() crash

From: Goetz Babin-Ebell <gbabinebell_at_betrusted.com>
Date: Fri, 01 Oct 2004 13:21:11 +0200

Hello Gisele

Gisle Vanem wrote:
> A command like "curl --form=@foo .." crashes in strippath()
> where strdup() is given an address 1 from basename.
>
> I think this basename() is better:
>
> --- CVS-latest/lib/formdata.c Fri Oct 01 08:36:11 2004
> +++ lib/formdata.c Fri Oct 01 12:09:12 2004
> @@ -944,7 +944,7 @@
> if(s1 && s2) {
> path = (s1 > s2? s1 : s2)+1;
> }
> - else {
> + else if (s1 || s2) {
> path = (s1 ? s1 : s2)+1;
> }

I think a

   else if (s1)
     path = s1+1;
   else if (s2)
     path = s2+1;

is simpler (and easier to read...)

Bye

Goetz

-- 
Goetz Babin-Ebell, software designer,
TC TrustCenter AG, Sonninstr. 24-28, 20097 Hamburg, Germany
Office: +49-(0)40 80 80 26 -0,  Fax: +49-(0)40 80 80 26 -126
www.trustcenter.de www.betrusted.com

Received on 2004-10-01