diff options
author | Karel Klic <kklic@redhat.com> | 2009-10-30 17:25:36 +0100 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2009-10-30 17:25:36 +0100 |
commit | d6f85d204994b7f4a7afe943f4d5fa873599cd01 (patch) | |
tree | 6ab239e4f2583dc53218e0971cf6236d9567efc8 | |
parent | f92e5d5587e57c6319d3fd8bdd351918fad27721 (diff) | |
download | abrt-d6f85d204994b7f4a7afe943f4d5fa873599cd01.tar.gz abrt-d6f85d204994b7f4a7afe943f4d5fa873599cd01.tar.xz abrt-d6f85d204994b7f4a7afe943f4d5fa873599cd01.zip |
Python backtrace size limited to 1 MB
-rw-r--r-- | src/Hooks/abrt-pyhook-helper.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Hooks/abrt-pyhook-helper.cpp b/src/Hooks/abrt-pyhook-helper.cpp index 7ad605f3..f8bda846 100644 --- a/src/Hooks/abrt-pyhook-helper.cpp +++ b/src/Hooks/abrt-pyhook-helper.cpp @@ -98,20 +98,26 @@ int main(int argc, char** argv) char *bt = (char*)malloc(capacity); if (!bt) { - printf("Error while allocating memory for backtrace.\n"); + fprintf(stderr, "Error while allocating memory for backtrace.\n"); return 1; } char *btptr = bt; while ((c = getchar()) != EOF) { - *btptr++ = (char)c; + *btptr++ = (char)c; if (btptr - bt >= capacity - 1) { capacity *= 2; + if (capacity > 1048576) // > 1 MB + { + fprintf(stderr, "Backtrace size limit exceeded. Trimming to 1 MB.\n"); + break; + } + bt = (char*)realloc(bt, capacity); if (!bt) { - printf("Error while allocating memory for backtrace.\n"); + fprintf(stderr, "Error while allocating memory for backtrace.\n"); return 1; } } |