]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
libssh: error on bad chgrp number
authorDaniel Stenberg <daniel@haxx.se>
Sat, 20 Sep 2025 09:25:38 +0000 (11:25 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 20 Sep 2025 10:05:31 +0000 (12:05 +0200)
To avoid it continuing with a zero gid.

Reported in Joshua's sarif data

Closes #18629

lib/vssh/libssh.c

index 2554468c4bf30d727cc9b3bfc10edb09397a79ce..be8336ad0a1ef0d0eb6d336991f35d821ac38a8c 100644 (file)
@@ -1808,10 +1808,7 @@ static int myssh_in_SFTP_QUOTE_STAT(struct Curl_easy *data,
   if(!strncmp(cmd, "chgrp", 5)) {
     const char *p = sshc->quote_path1;
     curl_off_t gid;
-    (void)curlx_str_number(&p, &gid, UINT_MAX);
-    sshc->quote_attrs->gid = (uint32_t)gid;
-    if(sshc->quote_attrs->gid == 0 && !ISDIGIT(sshc->quote_path1[0]) &&
-       !sshc->acceptfail) {
+    if(curlx_str_number(&p, &gid, UINT_MAX)) {
       Curl_safefree(sshc->quote_path1);
       Curl_safefree(sshc->quote_path2);
       failf(data, "Syntax error: chgrp gid not a number");
@@ -1820,6 +1817,7 @@ static int myssh_in_SFTP_QUOTE_STAT(struct Curl_easy *data,
       sshc->actualcode = CURLE_QUOTE_ERROR;
       return SSH_NO_ERROR;
     }
+    sshc->quote_attrs->gid = (uint32_t)gid;
     sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID;
   }
   else if(!strncmp(cmd, "chmod", 5)) {