gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnurl] 25/73: mime: refuse to add subparts to one of their


From: gnunet
Subject: [GNUnet-SVN] [gnurl] 25/73: mime: refuse to add subparts to one of their own descendants.
Date: Tue, 24 Oct 2017 18:54:06 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit ebcbed3821533a884e18f9441084da9449514fdf
Author: Patrick Monnerat <address@hidden>
AuthorDate: Sun Oct 8 18:49:52 2017 +0100

    mime: refuse to add subparts to one of their own descendants.
    
    Reported-by: Alexey Melnichuk
    Fixes #1962
---
 lib/mime.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lib/mime.c b/lib/mime.c
index 4b6881703..04746ed09 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -26,6 +26,8 @@
 
 #include "mime.h"
 #include "non-ascii.h"
+#include "urldata.h"
+#include "sendf.h"
 
 #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
     !defined(CURL_DISABLE_IMAP)
@@ -1409,6 +1411,8 @@ CURLcode curl_mime_data_cb(curl_mimepart *part, 
curl_off_t datasize,
 CURLcode Curl_mime_set_subparts(curl_mimepart *part,
                                 curl_mime *subparts, int take_ownership)
 {
+  curl_mime *root;
+
   if(!part)
     return CURLE_BAD_FUNCTION_ARGUMENT;
 
@@ -1427,6 +1431,17 @@ CURLcode Curl_mime_set_subparts(curl_mimepart *part,
     if(subparts->parent)
       return CURLE_BAD_FUNCTION_ARGUMENT;
 
+    /* Should not be the part's root. */
+    root = part->parent;
+    if(root) {
+      while(root->parent && root->parent->parent)
+        root = root->parent->parent;
+      if(subparts == root) {
+        failf(part->easy, "Can't add itself as a subpart!");
+        return CURLE_BAD_FUNCTION_ARGUMENT;
+      }
+    }
+
     subparts->parent = part;
     part->readfunc = mime_subparts_read;
     part->seekfunc = mime_subparts_seek;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]