Fixes crash when searching kerberos usernames

Fixes

(gdb) f 0
101                         if(cname_str[cname_len-1] == '$') {
(gdb) p cname_len
$3 = 0
This commit is contained in:
Simone Mainardi 2019-11-19 11:34:34 +01:00
parent da029607a0
commit 3754e6dd12

View file

@ -98,7 +98,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
#endif
/* if cname does not end with a $ then it's a username */
if(cname_str[cname_len-1] == '$') {
if(cname_len && cname_str[cname_len-1] == '$') {
cname_str[cname_len-1] = '\0';
snprintf(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname), "%s", cname_str);
} else
@ -184,7 +184,7 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
printf("[Kerberos Cname][len: %u][%s]\n", cname_len, cname_str);
#endif
if(cname_str[cname_len-1] == '$') {
if(cname_len && cname_str[cname_len-1] == '$') {
cname_str[cname_len-1] = '\0';
snprintf(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname), "%s", cname_str);
} else