summaryrefslogtreecommitdiff
path: root/lib/file.c
Commit message (Collapse)AuthorAgeFilesLines
* conn: add 'attach' to protocol handler, make libssh2 use itDaniel Stenberg2021-05-171-0/+1
| | | | | | | | | | | The libssh2 backend has SSH session associated with the connection but the callback context is the easy handle, so when a connection gets attached to a transfer, the protocol handler now allows for a custom function to get used to set things up correctly. Reported-by: Michael O'Farrell Fixes #6898 Closes #7078
* lib: remove strlen call from Curl_client_writeJacob Hoffman-Andrews2021-04-291-5/+7
| | | | | | | At all call sites with an explicit 0 len, pass an appropriate nonzero len. Closes #6954
* file: support GETing directories againLuke Granger-Brown2021-04-051-12/+17
| | | | | | | | | | | | | | After 957bc1881e686f9714c4e6a01bf33535091f0e21, we no longer compute an expected_size for directories. This has the upshot that when we compare even an empty Range with the available size, we fail. This brings back the previous behaviour, which was to succeed, but with empty content. This also removes the "Accept-ranges: bytes" header, which is nonsensical on directories. Adds test 3016 Fixes #6845 Closes #6846
* curl_range: remove conn->dataDaniel Stenberg2021-01-201-2/+1
| | | | Closes #6496
* transfer: remove conn->data useDaniel Stenberg2021-01-191-2/+1
| | | | Closes #6486
* lib: more conn->data cleanupsDaniel Stenberg2021-01-191-4/+4
| | | | Closes #6479
* lib: pass in 'struct Curl_easy *' to most functionsDaniel Stenberg2021-01-171-32/+37
| | | | | | | | | | | | | | | | | | | | | ... in most cases instead of 'struct connectdata *' but in some cases in addition to. - We mostly operate on transfers and not connections. - We need the transfer handle to log, store data and more. Everything in libcurl is driven by a transfer (the CURL * in the public API). - This work clarifies and separates the transfers from the connections better. - We should avoid "conn->data". Since individual connections can be used by many transfers when multiplexing, making sure that conn->data points to the current and correct transfer at all times is difficult and has been notoriously error-prone over the years. The goal is to ultimately remove the conn->data pointer for this reason. Closes #6425
* file: don't provide content-length for directoriesDaniel Stenberg2021-01-071-10/+12
| | | | | | | ... as it is misleading. Ref #6379 Closes #6421
* file: avoid duplicated code sequenceEmil Engler2020-11-251-11/+1
| | | | | | | | | file_disconnect() is identical with file_do() except the function header but as the arguments are unused anyway so why not just return file_do() directly! Reviewed-by: Daniel Stenberg Closes #6249
* urldata: remove 'void *protop' and create the union 'p'Daniel Stenberg2020-11-231-7/+7
| | | | | | | ... to avoid the use of 'void *' for the protocol specific structs done per transfer. Closes #6238
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* symbian: drop supportDaniel Stenberg2020-09-221-2/+1
| | | | | | | | | The OS is deprecated. I see no traces of anyone having actually built curl for Symbian after 2012. The public headers are unmodified. Closes #5989
* Curl_handler: add 'family' to each protocolDaniel Stenberg2020-09-211-0/+1
| | | | | | | Makes get_protocol_family() faster and it moves the knowledge about the "families" to each protocol handler, where it belongs. Closes #5986
* escape: make the URL decode able to reject only %00 bytesDaniel Stenberg2020-06-251-1/+1
| | | | | | ... or all "control codes" or nothing. Assisted-by: Nicolas Sterchele
* Revert "file: on Windows, refuse paths that start with \\"Daniel Stenberg2020-04-111-4/+2
| | | | | | | | | This reverts commit 1b71bc532bde8621fd3260843f8197182a467ff2. Reminded-by: Chris Roberts Bug: https://curl.haxx.se/mail/archive-2020-04/0013.html Closes #5215
* file: fix copyright year rangeDaniel Stenberg2020-01-061-1/+1
| | | | Follow-up to 1b71bc532bd
* file: on Windows, refuse paths that start with \\Daniel Stenberg2020-01-061-2/+4
| | | | | | | | | ... as that might cause an unexpected SMB connection to a given host name. Reported-by: Fernando Muñoz CVE-2019-15601 Bug: https://curl.haxx.se/docs/CVE-2019-15601.html
* file: fix "Checking if unsigned variable 'readcount' is less than zero."Daniel Stenberg2019-03-121-2/+2
| | | | | | Pointed out by codacy Closes #3672
* snprintf: renamed and we now only use msnprintf()Daniel Stenberg2018-11-231-12/+13
| | | | | | | | | | | The function does not return the same value as snprintf() normally does, so readers may be mislead into thinking the code works differently than it actually does. A different function name makes this easier to detect. Reported-by: Tomas Hoger Assisted-by: Daniel Gustafsson Fixes #3296 Closes #3297
* FILE: fix CURLOPT_NOBODY and CURLOPT_HEADER outputDaniel Stenberg2018-10-081-14/+13
| | | | | | | | | | | | | | | Now FILE transfers send headers to the header callback like HTTP and other protocols. Also made curl_easy_getinfo(...CURLINFO_PROTOCOL...) work for FILE in the callbacks. Makes "curl -i file://.." and "curl -I file://.." work like before again. Applied the bold header logic to them too. Regression from c1c2762 (7.61.0) Reported-by: Shaun Jackman Fixes #3083 Closes #3101
* url: use the URL API internally as wellDaniel Stenberg2018-09-221-2/+2
| | | | | | ... to make it a truly unified URL parser. Closes #3017
* CURLOPT_UPLOAD_BUFFERSIZE: set upload buffer sizeDaniel Stenberg2018-09-061-1/+1
| | | | | | | This is step 3 of #2888. Fixes #2888 Closes #2896
* all: s/int/size_t cleanupDaniel Stenberg2018-09-011-2/+2
| | | | | | Assisted-by: Rikard Falkeborn Closes #2922
* cppcheck: fix warningsMarian Klymov2018-06-111-3/+3
| | | | | | | | | | | | | - Get rid of variable that was generating false positive warning (unitialized) - Fix issues in tests - Reduce scope of several variables all over etc Closes #2631
* spelling fixesViktor Szakats2018-06-031-1/+1
| | | | | | Detected using the `codespell` tool (version 1.13.0). Also secure and fix an URL.
* time_t-fixes: remove typecasts to 'long' for info.filetimeDaniel Stenberg2018-02-011-3/+3
| | | | | | | | They're now wrong. Reported-by: Michael Kaufmann Closes #2277
* file: Check the return code from Curl_range and bail out on errorMax Dymond2018-01-301-1/+3
|
* Curl_range: commonize FTP and FILE range handlingMax Dymond2018-01-301-60/+2
| | | | Closes #2205
* time: rename Curl_tvnow to Curl_nowDaniel Stenberg2017-10-251-2/+2
| | | | | | | | | | ... since the 'tv' stood for timeval and this function does not return a timeval struct anymore. Also, cleaned up the Curl_timediff*() functions to avoid typecasts and clean up the descriptive comments. Closes #2011
* file_range: avoid integer overflow when figuring out byte rangeDaniel Stenberg2017-09-231-0/+3
| | | | | | | | | | | When trying to bump the value with one and the value is already at max, it causes an integer overflow. Closes #1908 Detected by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3465 Assisted-by: Max Dymond
* code style: use spaces around plusesDaniel Stenberg2017-09-111-1/+1
|
* code style: use spaces around equals signsDaniel Stenberg2017-09-111-5/+5
|
* strtoofft: reduce integer overflow risks globallyDaniel Stenberg2017-08-141-11/+13
| | | | | | | ... make sure we bail out on overflows. Reported-by: Brian Carpenter Closes #1758
* file: output the correct buffer to the userEven Rouault2017-08-071-1/+1
| | | | | | | | | | Regression brought by 7c312f84ea930d8 (April 2017) CVE-2017-1000099 Bug: https://curl.haxx.se/docs/adv_20170809C.html Credit to OSS-Fuzz for the discovery
* handler: refactor connection checkingMax Dymond2017-06-301-0/+1
| | | | | | Add a new type of callback to Curl_handler which performs checks on the connection. Alter RTSP so that it uses this callback to do its own check on connection health.
* file: make speedcheck use current time for checksDaniel Stenberg2017-06-071-4/+2
| | | | | | | ... as it would previously just get the "now" timestamp before the transfer starts and then not update it again. Closes #1550
* buffer: use data->set.buffer_size instead of BUFSIZEDaniel Stenberg2017-05-011-4/+3
| | | | ... to properly use the dynamically set buffer size!
* upload: UPLOAD_BUFSIZE is now for the upload bufferDaniel Stenberg2017-05-011-1/+1
|
* file: use private buffer for C-L outputDaniel Stenberg2017-05-011-4/+5
| | | | ... instead of clobbering the download buffer.
* Improve code readbilitySylvestre Ledru2017-03-131-4/+2
| | | | | | ... by removing the else branch after a return, break or continue. Closes #1310
* CURLOPT_BUFFERSIZE: support enlarging receive bufferRichy Kim2017-01-191-1/+1
| | | | | | | | | | Replace use of fixed macro BUFSIZE to define the size of the receive buffer. Reappropriate CURLOPT_BUFFERSIZE to include enlarging receive buffer size. Upon setting, resize buffer if larger than the current default size up to a MAX_BUFSIZE (512KB). This can benefit protocols like SFTP. Closes #1222
* checksrc: code style: use 'char *name' styleDaniel Stenberg2016-11-241-1/+1
|
* file: fix compiler warningMichael Kaufmann2016-11-011-1/+1
| | | | follow-up to 46133aa5
* escape: avoid using curl_easy_unescape() internallyDaniel Stenberg2016-10-311-4/+5
| | | | Since the internal Curl_urldecode() function has a better API.
* library: Fix memory leaks found during static analysisMiroslav Franc2016-07-141-2/+6
| | | | Closes https://github.com/curl/curl/pull/913
* internals: rename the SessionHandle struct to Curl_easyDaniel Stenberg2016-06-221-4/+4
|
* lib: include curl_printf.h as one of the last headersDaniel Stenberg2016-04-291-2/+1
| | | | | | | | | | | | | | | | | | | | curl_printf.h defines printf to curl_mprintf, etc. This can cause problems with external headers which may use __attribute__((format(printf, ...))) markers etc. To avoid that they cause problems with system includes, we include curl_printf.h after any system headers. That makes the three last headers to always be, and we keep them in this order: curl_printf.h curl_memory.h memdebug.h None of them include system headers, they all do funny #defines. Reported-by: David Benjamin Fixes #743
* code: style updatesDaniel Stenberg2016-04-031-1/+1
|
* file: remove duplicate checks of the same variableDaniel Stenberg2016-03-311-23/+21
| | | | | | ... as it doesn't change in between. Deteced by PVS Studio. Reported-by: Alexis La Goutte
* file: try reading from files with no sizeDaniel Stenberg2016-02-251-8/+18
| | | | | | | | | | | Some systems have special files that report as 0 bytes big, but still contain data that can be read (for example /proc/cpuinfo on Linux). Starting now, a zero byte size is considered "unknown" size and will be read as far as possible anyway. Reported-by: Jesse Tan Closes #681