]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1545: test doing curl_formadd twice with missing file
authorDaniel Stenberg <daniel@haxx.se>
Tue, 28 Nov 2023 10:01:54 +0000 (11:01 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 28 Nov 2023 21:57:42 +0000 (22:57 +0100)
Reproduces #12410
Verifies the fix
Closes #12421

tests/data/Makefile.inc
tests/data/test1545 [new file with mode: 0644]
tests/libtest/Makefile.inc
tests/libtest/lib1545.c [new file with mode: 0644]

index a1a016554d43089ae701fb3db5a97743db8cb773..2608e16d6e6dd7a27b1d8b884a658d93e78332d9 100644 (file)
@@ -193,7 +193,7 @@ test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
 test1516 test1517 test1518 test1519 test1520 test1521 test1522 test1523 \
 test1524 test1525 test1526 test1527 test1528 test1529 test1530 test1531 \
 test1532 test1533 test1534 test1535 test1536 test1537 test1538 test1539 \
-test1540          test1542 test1543 test1544 \
+test1540          test1542 test1543 test1544 test1545 \
 \
 test1550 test1551 test1552 test1553 test1554 test1555 test1556 test1557 \
 test1558 test1559 test1560 test1561 test1562 test1563 test1564 test1565 \
diff --git a/tests/data/test1545 b/tests/data/test1545
new file mode 100644 (file)
index 0000000..477b5bf
--- /dev/null
@@ -0,0 +1,38 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<features>
+form-api
+</features>
+<server>
+http
+</server>
+# tool is what to use instead of 'curl'
+<tool>
+lib%TESTNUMBER
+</tool>
+
+<name>
+use curl_formadd() data twice with unreadable file
+</name>
+<command>
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+</verify>
+</testcase>
index d7f1de2a3bcca384535c0c19087b8c0e57481f38..c4d36a26b3fcc77671ccea39eb9314f4b141e639 100644 (file)
@@ -58,7 +58,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect libprereq      \
  lib1518         lib1520 lib1521 lib1522 lib1523 \
  lib1525 lib1526 lib1527 lib1528 lib1529 lib1530 lib1531 lib1532 lib1533 \
  lib1534 lib1535 lib1536 lib1537 lib1538 lib1539 \
- lib1540         lib1542 lib1543 \
+ lib1540         lib1542 lib1543         lib1545 \
  lib1550 lib1551 lib1552 lib1553 lib1554 lib1555 lib1556 lib1557 \
  lib1558 lib1559 lib1560 lib1564 lib1565 lib1567 lib1568 lib1569 \
  lib1591 lib1592 lib1593 lib1594 lib1596 lib1597 \
@@ -467,6 +467,9 @@ lib1542_LDADD = $(TESTUTIL_LIBS)
 lib1543_SOURCES = lib1518.c $(SUPPORTFILES)
 lib1543_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1543
 
+lib1545_SOURCES = lib1545.c $(SUPPORTFILES)
+lib1545_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_DISABLE_DEPRECATION
+
 lib1550_SOURCES = lib1550.c $(SUPPORTFILES)
 
 lib1551_SOURCES = lib1551.c $(SUPPORTFILES)
diff --git a/tests/libtest/lib1545.c b/tests/libtest/lib1545.c
new file mode 100644 (file)
index 0000000..9278b2a
--- /dev/null
@@ -0,0 +1,53 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "test.h"
+
+int test(char *URL)
+{
+  CURL *eh = NULL;
+  int res = 0;
+  struct curl_httppost *lastptr = NULL;
+  struct curl_httppost *m_formpost = NULL;
+
+  global_init(CURL_GLOBAL_ALL);
+
+  easy_init(eh);
+
+  easy_setopt(eh, CURLOPT_URL, URL);
+  curl_formadd(&m_formpost, &lastptr, CURLFORM_COPYNAME, "file",
+               CURLFORM_FILE, "missing-file", CURLFORM_END);
+  curl_easy_setopt(eh, CURLOPT_HTTPPOST, m_formpost);
+
+  (void)curl_easy_perform(eh);
+  (void)curl_easy_perform(eh);
+
+test_cleanup:
+
+  curl_formfree(m_formpost);
+
+  curl_easy_cleanup(eh);
+  curl_global_cleanup();
+
+  return res;
+}