]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
smb: return error on upload without size
authorDaniel Stenberg <daniel@haxx.se>
Sun, 12 Feb 2023 12:24:08 +0000 (13:24 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 12 Feb 2023 17:04:41 +0000 (18:04 +0100)
The protocol needs to know the size ahead of time, this is now a known
restriction and not a bug.

Also output a clearer error if the URL path does not contain proper
share.

Ref: #7896
Closes #10484

docs/KNOWN_BUGS
docs/URL-SYNTAX.md
lib/smb.c

index cbf5be352a2791fbdb501429debe188908d2b77a..a515e7a59bdfd45ecce3b318c946975a595505a0 100644 (file)
@@ -45,7 +45,6 @@ problems may have been fixed or changed somewhat since this was written.
  5.6 make distclean loops forever
  5.8 configure finding libs in wrong directory
  5.9 Utilize Requires.private directives in libcurl.pc
- 5.10 curl hangs on SMB upload over stdin
  5.11 configure --with-gssapi with Heimdal is ignored on macOS
  5.12 flaky Windows CI builds
  5.13 long paths are not fully supported on Windows
@@ -332,10 +331,6 @@ problems may have been fixed or changed somewhat since this was written.
 
  https://github.com/curl/curl/issues/864
 
-5.10 curl hangs on SMB upload over stdin
-
- See https://github.com/curl/curl/issues/7896
-
 5.11 configure --with-gssapi with Heimdal is ignored on macOS
 
  ... unless you also pass --with-gssapi-libs
index 691fcceacd66cf0a8bce45a1fa1af5fe83207952..802bbdef96979b158c453d55af3c74e023666d4e 100644 (file)
@@ -360,6 +360,9 @@ share and directory or the share to upload to and as such, may not be omitted.
 If the user name is embedded in the URL then it must contain the domain name
 and as such, the backslash must be URL encoded as %2f.
 
+When uploading to SMB, the size of the file needs to be known ahead of time,
+meaning that you can upload a file passed to curl over a pipe like stdin.
+
 curl supports SMB version 1 (only)
 
 ## SMTP
index 8a76763c157ce4d1decb15e3785a46b46a49bcc5..dc0abe784bcee523657532245b362d61cedf4ebb 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -763,6 +763,11 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done)
   void *msg = NULL;
   const struct smb_nt_create_response *smb_m;
 
+  if(data->set.upload && (data->state.infilesize < 0)) {
+    failf(data, "SMB upload needs to know the size up front");
+    return CURLE_SEND_ERROR;
+  }
+
   /* Start the request */
   if(req->state == SMB_REQUESTING) {
     result = smb_send_tree_connect(data);
@@ -993,6 +998,7 @@ static CURLcode smb_parse_url_path(struct Curl_easy *data,
   /* The share must be present */
   if(!slash) {
     Curl_safefree(smbc->share);
+    failf(data, "missing share in URL path for SMB");
     return CURLE_URL_MALFORMAT;
   }