cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: URL parsing

From: Tor Arntsen <kspt.tor_at_gmail.com>
Date: Fri, 19 Apr 2013 16:36:35 +0200

On 19 April 2013 10:48, Steve Holme <steve_holme_at_hotmail.com> wrote:
> Hi all,
>
> On Sun, 14 Apr 2013, Steve Holme wrote:
>
>> I've got a little stuck, as I'm not too sure which the best approach here
>> is, so wondered if you could provide a little guidance please?
>
> I figured out a solution and am half way through pushing my changes to
> master.
>
> Unfortunately, I have broken test case 131 along the way with a valgrind
> error and as a Windows programmer I don't seem to be able to figure out the
> error of my ways :(
>
> Would someone be so kind to take a look at parse_login_details() in url.c
> (specifically the malloc at line 4510) please to see what I have done wrong?

I just did a quick check, no fix, but there is a problem in url.c,
function parse_login_details():

This:
  plen = (psep ?
          (osep && osep > psep ? (size_t)(osep - psep) :
                                 (size_t)(login + len - psep)) - 1 : 0);

sets 'plen' = -1, which creates several probems. I have a test with a
coredump in memcpy at line 4535 : memcpy(ptemp, psep + 1, plen);
and when running valgrind I get a 'silly malloc argument: -16' at one point.

In the above I see:

(gdb) print olen
$9 = 0
(gdb) print psep
$11 = 0x21aced7 ""
(gdb) print osep
$12 = 0x0
(gdb) print plen
$8 = 18446744073709551605
(that's basically 0x3fff......)
(gdb) print login
$5 = 0x21acec8 ""
(gdb) print len
$13 = 5
(gdb) print ulen
$16 = 15

Unfortunately I just had a few minutes in between other stuff so I
can't anlyze further. But it appears that it is unable to handle the
particular parameters.

#0 __memcpy_ssse3 () at ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:2820
#1 0x00007f6e32a6f2aa in parse_login_details (login=0x21acec8 "", len=5,
    userp=0x7fff81aaa218, passwdp=0x7fff81aaa210, optionsp=0x7fff81aaa208)
    at url.c:4535
#2 0x00007f6e32a6edb4 in parse_url_login (data=0x2187588, conn=0x21ac708,
    user=0x7fff81aaa590 "", passwd=0x7fff81aaa490 "",
    options=0x7fff81aaa390 "") at url.c:4386
#3 0x00007f6e32a6df59 in parseurlandfillconn (data=0x2187588, conn=0x21ac708,
    prot_missing=0x7fff81aaa38f, user=0x7fff81aaa590 "",
    passwd=0x7fff81aaa490 "", options=0x7fff81aaa390 "") at url.c:3875
#4 0x00007f6e32a70329 in create_conn (data=0x2187588, in_connect=0x21a29b0,
    async=0x7fff81aaa79a) at url.c:4994
#5 0x00007f6e32a7113f in Curl_connect (data=0x2187588, in_connect=0x21a29b0,
    asyncp=0x7fff81aaa79a, protocol_done=0x7fff81aaa799) at url.c:5495
#6 0x00007f6e32a8b5f8 in multi_runsingle (multi=0x2190908, now=...,
    easy=0x21a2998) at multi.c:1014
#7 0x00007f6e32a8cc19 in curl_multi_perform (multi_handle=0x2190908,
    running_handles=0x7fff81aaa8a0) at multi.c:1720
#8 0x00007f6e32a81dff in curl_easy_perform (easy=0x2187588) at easy.c:475
#9 0x00000000004109fa in operate (config=0x7fff81aaad80, argc=11,
    argv=0x7fff81aab208) at tool_operate.c:1357
#10 0x000000000040bb15 in main (argc=11, argv=0x7fff81aab208)
    at tool_main.c:100
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-19