[LIBREPORT RHEL6 PATCH 2/3] reporter-bugzilla: use base64 XMLRPC type for encoded data instead of string type

Jakub Filak jfilak at redhat.com
Tue Aug 13 11:55:46 UTC 2013


- obsolete: 'bugzilla.addAttachment' accepted base64 data in string variable
  and stored them in database decoded

- current: 'Bug.add_attachment' accepts base64 data but it must be stored in
  base64 type, otherwise server doesn't decode the data and stores them as they
  are

- related to issue #117

Related to rhbz#991088

Signed-off-by: Jakub Filak <jfilak at redhat.com>
Signed-off-by: Jiri Moskovcak <jmoskovc at redhat.com>
---
 src/plugins/rhbz.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/plugins/rhbz.c b/src/plugins/rhbz.c
index fb00f60..9283b81 100644
--- a/src/plugins/rhbz.c
+++ b/src/plugins/rhbz.c
@@ -767,18 +767,27 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename,
 {
     func_entry();
 
-    char *encoded64 = encode_base64(data, data_len);
     char *fn = xasprintf("File: %s", filename);
     xmlrpc_value* result;
     int nomail_notify = !!IS_NOMAIL_NOTIFY(flags);
 
-    /* http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html#add_attachment */
-    result = abrt_xmlrpc_call(ax, "Bug.add_attachment", "({s:(s),s:s,s:s,s:s,s:s,s:i})",
+    /* http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html#add_attachment
+     *
+     * XMLRPC format options:
+     *   s -> string,  single argument (char* value)
+     *   i -> integer, single argument (int value)
+     *   6 -> base64,  two arguments (char* plain data which will be encoded by xmlrpc-c to base64,
+     *                                size_t number of bytes to encode)
+     */
+    result = abrt_xmlrpc_call(ax, "Bug.add_attachment", "({s:(s),s:s,s:s,s:s,s:6,s:i})",
                 "ids", bug_id,
                 "summary", fn,
                 "file_name", filename,
                 "content_type", (flags & RHBZ_BINARY_ATTACHMENT) ? "application/octet-stream" : "text/plain",
-                "data", encoded64,
+                /* base64 type requires two arguments: char* (plain data) and size_t (length)
+                 * ! xmlrpc-c takes care about encoding to base64 !
+                 */
+                "data", data, (size_t)data_len,
 
                 /* Undocumented argument but it works with Red Hat Bugzilla version 4.2.4-7
                  * and version 4.4.rc1.b02
@@ -786,7 +795,6 @@ int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename,
                 "nomail", nomail_notify
     );
 
-    free(encoded64);
     free(fn);
     if (!result)
         return -1;
-- 
1.8.3.1



More information about the Crash-catcher mailing list