From af9d08603376932916b4611abe26df9ffa4910b3 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Mon, 10 Jul 2017 11:15:40 +0800 Subject: [PATCH] =?UTF-8?q?SFH=20minor=20bug=20fix=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/stream_fuzzy_hash.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/entry/stream_fuzzy_hash.c b/src/entry/stream_fuzzy_hash.c index 515bc67..4006b61 100644 --- a/src/entry/stream_fuzzy_hash.c +++ b/src/entry/stream_fuzzy_hash.c @@ -598,17 +598,21 @@ int SFH_digest(sfh_instance_t * handle, char * hash_buffer, unsigned int size) { hash_buffer[0]='\0'; goto fast_out; - } - p =strrchr(result.hash_b1,'['); - assert(p!=NULL); - memmove(p+1,p,strlen(p)); - *p=result.last_char_b1; - - p =strrchr(result.hash_b2,'['); - assert(p!=NULL); - memmove(p+1,p,strlen(p)); - *p=result.last_char_b2; - + } + if(result.last_char_b1!='\0') + { + p =strrchr(result.hash_b1,'['); + assert(p!=NULL); + memmove(p+1,p,strlen(p)); + *p=result.last_char_b1; + } + if(result.last_char_b2!='\0') + { + p =strrchr(result.hash_b2,'['); + assert(p!=NULL); + memmove(p+1,p,strlen(p)); + *p=result.last_char_b2; + } actual_len=snprintf(hash_buffer,size,"%llu:%s#%llu:%s",result.b1,result.hash_b1, result.b2,result.hash_b2); fast_out: