summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-05-22 21:28:58 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-05-22 21:28:58 +0200
commit1fef96e2031952fccc4cf9ed189b50fec9360a06 (patch)
tree861d8a81ff6d093806b32c0b9fafb88143963df6 /src/plugins
parentcba90f009109235ce653b0e41bb7c50d66d48a94 (diff)
downloadabrt-1fef96e2031952fccc4cf9ed189b50fec9360a06.tar.gz
abrt-1fef96e2031952fccc4cf9ed189b50fec9360a06.tar.xz
abrt-1fef96e2031952fccc4cf9ed189b50fec9360a06.zip
assorted cleanups, memory leak fix (g_list_free in add_basics_to_problem_data)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/abrt-action-analyze-backtrace.c14
-rw-r--r--src/plugins/abrt-action-analyze-c.c15
-rw-r--r--src/plugins/abrt-action-analyze-oops.c14
-rw-r--r--src/plugins/abrt-action-analyze-python.c14
4 files changed, 8 insertions, 49 deletions
diff --git a/src/plugins/abrt-action-analyze-backtrace.c b/src/plugins/abrt-action-analyze-backtrace.c
index 5d8c77f6..43293c0b 100644
--- a/src/plugins/abrt-action-analyze-backtrace.c
+++ b/src/plugins/abrt-action-analyze-backtrace.c
@@ -26,23 +26,13 @@ static const char *dump_dir_name = ".";
static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput)
{
- unsigned char hash_bytes[SHA1_RESULT_LEN];
+ char hash_bytes[SHA1_RESULT_LEN];
sha1_ctx_t sha1ctx;
sha1_begin(&sha1ctx);
sha1_hash(&sha1ctx, pInput, strlen(pInput));
sha1_end(&sha1ctx, hash_bytes);
- unsigned len = SHA1_RESULT_LEN;
- unsigned char *s = hash_bytes;
- char *d = hash_str;
- while (len)
- {
- *d++ = "0123456789abcdef"[*s >> 4];
- *d++ = "0123456789abcdef"[*s & 0xf];
- s++;
- len--;
- }
- *d = '\0';
+ bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
//log("hash:%s str:'%s'", hash_str, pInput);
}
diff --git a/src/plugins/abrt-action-analyze-c.c b/src/plugins/abrt-action-analyze-c.c
index 487fb8f7..240ca2a2 100644
--- a/src/plugins/abrt-action-analyze-c.c
+++ b/src/plugins/abrt-action-analyze-c.c
@@ -21,24 +21,13 @@
static void create_hash(char hash_str[SHA1_RESULT_LEN*2 + 1], const char *pInput)
{
- unsigned char hash_bytes[SHA1_RESULT_LEN];
-
+ char hash_bytes[SHA1_RESULT_LEN];
sha1_ctx_t sha1ctx;
sha1_begin(&sha1ctx);
sha1_hash(&sha1ctx, pInput, strlen(pInput));
sha1_end(&sha1ctx, hash_bytes);
- unsigned len = SHA1_RESULT_LEN;
- unsigned char *s = hash_bytes;
- char *d = hash_str;
- while (len)
- {
- *d++ = "0123456789abcdef"[*s >> 4];
- *d++ = "0123456789abcdef"[*s & 0xf];
- s++;
- len--;
- }
- *d = '\0';
+ bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
//log("hash:%s str:'%s'", hash_str, pInput);
}
diff --git a/src/plugins/abrt-action-analyze-oops.c b/src/plugins/abrt-action-analyze-oops.c
index 9485d3c8..02ba3e96 100644
--- a/src/plugins/abrt-action-analyze-oops.c
+++ b/src/plugins/abrt-action-analyze-oops.c
@@ -114,23 +114,13 @@ static void hash_oops_str(char hash_str[SHA1_RESULT_LEN*2 + 1], char *oops_buf,
gen_hash: ;
- unsigned char hash_bytes[SHA1_RESULT_LEN];
+ char hash_bytes[SHA1_RESULT_LEN];
sha1_ctx_t sha1ctx;
sha1_begin(&sha1ctx);
sha1_hash(&sha1ctx, oops_buf, dst - oops_buf);
sha1_end(&sha1ctx, hash_bytes);
- unsigned len = SHA1_RESULT_LEN;
- unsigned char *s = hash_bytes;
- char *d = hash_str;
- while (len)
- {
- *d++ = "0123456789abcdef"[*s >> 4];
- *d++ = "0123456789abcdef"[*s & 0xf];
- s++;
- len--;
- }
- *d = '\0';
+ bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
}
int main(int argc, char **argv)
diff --git a/src/plugins/abrt-action-analyze-python.c b/src/plugins/abrt-action-analyze-python.c
index 5a33fb8d..c991cfc2 100644
--- a/src/plugins/abrt-action-analyze-python.c
+++ b/src/plugins/abrt-action-analyze-python.c
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
/* Hash 1st line of backtrace and save it as UUID and DUPHASH */
/* "example.py:1:<module>:ZeroDivisionError: integer division or modulo by zero" */
- unsigned char hash_bytes[SHA1_RESULT_LEN];
+ char hash_bytes[SHA1_RESULT_LEN];
sha1_ctx_t sha1ctx;
sha1_begin(&sha1ctx);
const char *bt_end = strchrnul(bt, '\n');
@@ -62,17 +62,7 @@ int main(int argc, char **argv)
free(bt);
char hash_str[SHA1_RESULT_LEN*2 + 1];
- unsigned len = SHA1_RESULT_LEN;
- unsigned char *s = hash_bytes;
- char *d = hash_str;
- while (len)
- {
- *d++ = "0123456789abcdef"[*s >> 4];
- *d++ = "0123456789abcdef"[*s & 0xf];
- s++;
- len--;
- }
- *d = '\0';
+ bin2hex(hash_str, hash_bytes, SHA1_RESULT_LEN)[0] = '\0';
dd_save_text(dd, FILENAME_UUID, hash_str);
dd_save_text(dd, FILENAME_DUPHASH, hash_str);