cURL / Mailing Lists / curl-users / Single Mail

curl-users

BUG in VMS-CURL with http-Upload

From: Harald Schwarz <haschwar_at_gmx.de>
Date: Sun, 10 Aug 2008 10:56:22 +0200

Hello,
I found a bug in VMS-CURL on VMS - Alpha.
When using an http-file-upload the file is not sent to the Server with
the correct content-length if the file is stored with 512 Byte block-length.
Sending a file with 511 or less bytes, the wrong content-length 512 is used.
Sending a file with 513 - 1023 bytes, the wrong content-length 1024 is used.
Files with a length of a multiple of 512 show the correct content-length.

Details:
my code to upload a file was (on VMS):
curl = "$DRA3:[GUEST]CURL.EXE" <- predefinition required for VMS only
curl --form myfile=@test.bin http://my_intranet_server/cgi-bin/upload.pl

Tests on Windows and Linux with the same file succeeded in correct
file-upload (and correct content-length).
Test without file-upload on VMS also succeeded (option -d for
post-parameters)
Test with option -F on VMS resultet in a GET request instead of a POST
request. I discontinued the test with -F.

Similar Problems:
Searching curl-upload problems I found the same bug description for
ftp-put operation.

Where the problem could come from:
It seems to me that the stat and fstat function in the code do not
return the correct st_size on VMS. I already found a hint inside the c-code:
    /* VMS: This only works reliable for STREAMLF files */
    if( -1 != fstat(fd, &statbuf)) {
      /* we could stat it, then read out the size */
      expected_size = statbuf.st_size;
      fstated = TRUE;
    }

I found a hint on a different site describing VMS fstat-function:
_http://mx.isti.cnr.it/cgi-bin/conan?key=CRTL~fstat&explode=yes&title=VMS%20Help&referer=_
<http://mx.isti.cnr.it/cgi-bin/conan?key=CRTL%7Efstat&explode=yes&title=VMS%20Help&referer=>

    st_size off_t File size, in bytes. For st_size to
                             report a correct value, you need to
                             flush both the C RTL and RMS buffers.

A short solution idea of me is to override the fstat and stat function
for VMS in the part of returning the file-size. How the file-size could
be detected correctly is shown on following page:
_http://www.wer-weiss-was.de/theme158/article1634662.html_
(German language only, but the c-code at the end is readable).

But now my knowledge ends. I'm not a C-programmer and I do not have a
C-compiler for VMS.

Best regards,
Harald

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-08-10