summaryrefslogtreecommitdiffstats
path: root/src/plugins/abrt-action-analyze-python.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-04-18 14:23:19 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2011-04-18 14:23:19 +0200
commit0a41c4fdf4b242f77445a3e6d73443b40b6e460e (patch)
treee464a61df6653e91a2191950a6056ec70365fbd9 /src/plugins/abrt-action-analyze-python.c
parent305ba8e8786c32d5292d04e2ed25d1853479a23a (diff)
downloadabrt-0a41c4fdf4b242f77445a3e6d73443b40b6e460e.tar.gz
abrt-0a41c4fdf4b242f77445a3e6d73443b40b6e460e.tar.xz
abrt-0a41c4fdf4b242f77445a3e6d73443b40b6e460e.zip
switch python and oops hashing to sha1
Update sha1 code to a smaller version. Verified that ccpp hashing produces the same results as the old code. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins/abrt-action-analyze-python.c')
-rw-r--r--src/plugins/abrt-action-analyze-python.c45
1 files changed, 10 insertions, 35 deletions
diff --git a/src/plugins/abrt-action-analyze-python.c b/src/plugins/abrt-action-analyze-python.c
index 44e2d4b8..07f14a32 100644
--- a/src/plugins/abrt-action-analyze-python.c
+++ b/src/plugins/abrt-action-analyze-python.c
@@ -21,10 +21,6 @@
#define PROGNAME "abrt-action-analyze-python"
-// Hash is MD5_RESULT_LEN bytes long, but we use only first 4
-// (I don't know why old Python code was using only 4, I mimic that)
-#define HASH_STRING_HEX_DIGITS 4
-
int main(int argc, char **argv)
{
char *env_verbose = getenv("ABRT_VERBOSE");
@@ -63,41 +59,20 @@ int main(int argc, char **argv)
char *bt = dd_load_text(dd, FILENAME_BACKTRACE);
/* 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];
+ sha1_ctx_t sha1ctx;
+ sha1_begin(&sha1ctx);
const char *bt_end = strchrnul(bt, '\n');
- unsigned char hash_bytes[MD5_RESULT_LEN];
- md5_ctx_t md5ctx;
- md5_begin(&md5ctx);
- // Better:
- // "example.py:1:<module>:ZeroDivisionError: integer division or modulo by zero"
- //md5_hash(bt_str, bt_end - bt_str, &md5ctx);
- //free(bt);
- // For now using compat version:
- {
- char *copy = xstrndup(bt, bt_end - bt);
- free(bt);
- char *s = copy;
- char *d = copy;
- unsigned colon_cnt = 0;
- while (*s && colon_cnt < 3)
- {
- if (*s != ':')
- *d++ = *s;
- else
- colon_cnt++;
- s++;
- }
- // copy = "example.py1<module>"
- md5_hash(copy, d - copy, &md5ctx);
- free(copy);
- }
- // end of compat version
- md5_end(hash_bytes, &md5ctx);
+ sha1_hash(&sha1ctx, bt, bt_end - bt);
+ sha1_end(&sha1ctx, hash_bytes);
+ free(bt);
- char hash_str[HASH_STRING_HEX_DIGITS*2 + 1];
- unsigned len = HASH_STRING_HEX_DIGITS;
- char *d = hash_str;
+ 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];