Compile-tested only.
Please guys, both take a look at this patch.
It should help with this problem:
https://bugzilla.redhat.com/show_bug.cgi?id=733448
--
vda
diff -d -urpN libreport.8/src/lib/problem_data.c libreport.9/src/lib/problem_data.c
--- libreport.8/src/lib/problem_data.c 2011-08-30 13:16:19.778174262 +0200
+++ libreport.9/src/lib/problem_data.c 2011-08-30 16:33:39.447460724 +0200
@@ -236,9 +236,10 @@ static char* is_text_file(const char *na
* So, don't remove this. If you really need to, raise the limit.
*
* Bumped up to 200k: saw 124740 byte /proc/PID/smaps file
+ * Bumped up to 500k: saw 375252 byte anaconda traceback file
*/
off_t size = lseek(fd, 0, SEEK_END);
- if (size < 0 || size > 200*1024)
+ if (size < 0 || size > 500*1024)
{
close(fd);
return NULL; /* it's not a SMALL text */
diff -d -urpN libreport.8/src/plugins/report_Bugzilla.xml.in
libreport.9/src/plugins/report_Bugzilla.xml.in
--- libreport.8/src/plugins/report_Bugzilla.xml.in 2011-08-24 15:06:29.000000000 +0200
+++ libreport.9/src/plugins/report_Bugzilla.xml.in 2011-08-30 16:32:03.459040895 +0200
@@ -6,7 +6,7 @@
<requires-items>component,duphash,os_release</requires-items>
<exclude-items-by-default>coredump,count,event_log,reported_to,vmcore</exclude-items-by-default>
<exclude-items-always></exclude-items-always>
- <exclude-binary-items>yes</exclude-binary-items>
+ <exclude-binary-items>no</exclude-binary-items>
<include-items-by-default></include-items-by-default>
<minimal-rating>3</minimal-rating>
diff -d -urpN libreport.8/src/plugins/reporter-bugzilla.c
libreport.9/src/plugins/reporter-bugzilla.c
--- libreport.8/src/plugins/reporter-bugzilla.c 2011-08-30 12:48:10.557751346 +0200
+++ libreport.9/src/plugins/reporter-bugzilla.c 2011-08-30 16:27:25.875934263 +0200
@@ -113,7 +113,7 @@ static void report_to_bugzilla(const cha
char bug_id_str[sizeof(int)*3 + 2];
sprintf(bug_id_str, "%i", bug_id);
- rhbz_attachments(client, bug_id_str, problem_data, RHBZ_NOMAIL_NOTIFY);
+ rhbz_attach_big_files(client, bug_id_str, problem_data, RHBZ_NOMAIL_NOTIFY);
bz = new_bug_info();
bz->bi_status = xstrdup("NEW");
@@ -354,29 +354,8 @@ int main(int argc, char **argv)
continue;
}
- off_t size = lseek(fd, 0, SEEK_END);
- if (size < 0)
- {
- perror_msg("Can't lseek '%s'", filename);
- close(fd);
- continue;
- }
- lseek(fd, 0, SEEK_SET);
-
- /* FIXME: what if the file is tens of gigabytes? */
- char *data = xmalloc(size + 1);
- ssize_t r = full_read(fd, data, size);
- if (r < 0)
- {
- free(data);
- perror_msg("Can't read '%s'", filename);
- close(fd);
- continue;
- }
+ rhbz_attach_fd(client, filename, ticket_no, fd, /*flags*/ 0);
close(fd);
-
- rhbz_attachment(client, filename, ticket_no, data, r, /*flags*/ 0);
- free(data);
}
log(_("Logging out"));
diff -d -urpN libreport.8/src/plugins/rhbz.c libreport.9/src/plugins/rhbz.c
--- libreport.8/src/plugins/rhbz.c 2011-08-30 12:51:35.665963066 +0200
+++ libreport.9/src/plugins/rhbz.c 2011-08-30 16:37:58.825900264 +0200
@@ -380,7 +380,7 @@ int rhbz_new_bug(struct abrt_xmlrpc *ax,
}
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
-int rhbz_attachment(struct abrt_xmlrpc *ax, const char *filename,
+int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename,
const char *bug_id, const char *data, int data_len, int flags)
{
char *encoded64 = encode_base64(data, data_len);
@@ -406,8 +406,38 @@ int rhbz_attachment(struct abrt_xmlrpc *
return 0;
}
+int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename,
+ const char *bug_id, int fd, int flags)
+{
+ off_t size = lseek(fd, 0, SEEK_END);
+ if (size < 0)
+ {
+ perror_msg("Can't lseek '%s'", filename);
+ return -1;
+ }
+ if (size > INT_MAX / 2)
+ {
+ error_msg("Can't upload '%s', it's too large (%llu
bytes)", filename, (long long)size);
+ return -1;
+ }
+ lseek(fd, 0, SEEK_SET);
+
+ char *data = xmalloc(size + 1);
+ ssize_t r = full_read(fd, data, size);
+ if (r < 0)
+ {
+ free(data);
+ perror_msg("Can't read '%s'", filename);
+ return -1;
+ }
+
+ int res = rhbz_attach_blob(ax, filename, bug_id, data, size, flags);
+ free(data);
+ return res;
+}
+
/* suppress mail notify by {s:i} (nomail:1) (driven by flag) */
-int rhbz_attachments(struct abrt_xmlrpc *ax, const char *bug_id,
+int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags)
{
GHashTableIter iter;
@@ -427,9 +457,27 @@ int rhbz_attachments(struct abrt_xmlrpc
/* This text item wasn't added in comments, it is too big
* for that. Attach it as a file.
*/
- rhbz_attachment(ax, name, bug_id, content, len, flags);
+ rhbz_attach_blob(ax, name, bug_id, content, len, flags);
}
}
+ if (value->flags & CD_FLAG_BIN)
+ {
+ int fd = open(value->content, O_RDONLY);
+ if (fd < 0)
+ {
+ perror_msg("Can't open '%s'", value->content);
+ continue;
+ }
+ struct stat st;
+ if (fstat(fd, &st) != 0 || !S_ISREG(st.st_mode))
+ {
+ error_msg("'%s': not a regular file",
value->content);
+ close(fd);
+ continue;
+ }
+ rhbz_attach_fd(ax, name, bug_id, fd, flags);
+ close(fd);
+ }
}
return 0;
diff -d -urpN libreport.8/src/plugins/rhbz.h libreport.9/src/plugins/rhbz.h
--- libreport.8/src/plugins/rhbz.h 2011-08-30 12:48:17.626745937 +0200
+++ libreport.9/src/plugins/rhbz.h 2011-08-30 16:23:00.450020115 +0200
@@ -82,12 +82,15 @@ int rhbz_bug_id(xmlrpc_value *xml);
int rhbz_new_bug(struct abrt_xmlrpc *ax, problem_data_t *problem_data,
int depend_on_bug);
-int rhbz_attachments(struct abrt_xmlrpc *ax, const char *bug_id,
+int rhbz_attach_big_files(struct abrt_xmlrpc *ax, const char *bug_id,
problem_data_t *problem_data, int flags);
-int rhbz_attachment(struct abrt_xmlrpc *ax, const char *filename,
+int rhbz_attach_blob(struct abrt_xmlrpc *ax, const char *filename,
const char *bug_id, const char *data, int data_len, int flags);
+int rhbz_attach_fd(struct abrt_xmlrpc *ax, const char *filename,
+ const char *bug_id, int fd, int flags);
+
GList *rhbz_bug_cc(xmlrpc_value *result_xml);
struct bug_info *rhbz_bug_info(struct abrt_xmlrpc *ax, int bug_id);