aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/ssl.c
diff options
context:
space:
mode:
authorCampus <campus@ntop.org>2016-03-10 11:44:24 +0100
committerCampus <campus@ntop.org>2016-03-10 11:44:24 +0100
commit7ae06a114df358010c27cdf5819d1abdadd099fb (patch)
tree527d6fc3e841f7a9719c1c56117dd9690dc9645a /src/lib/protocols/ssl.c
parent8321b2fa66bb58fa85c36586b21deae8449d6465 (diff)
added check_punycode_string for issue https://github.com/ntop/nDPI/issues/157
Diffstat (limited to 'src/lib/protocols/ssl.c')
-rw-r--r--src/lib/protocols/ssl.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/lib/protocols/ssl.c b/src/lib/protocols/ssl.c
index bc0aa4f3c..2269ae782 100644
--- a/src/lib/protocols/ssl.c
+++ b/src/lib/protocols/ssl.c
@@ -92,11 +92,12 @@ static void ndpi_int_ssl_add_connection(struct ndpi_detection_module_struct *ndp
((ch) >= '{' && (ch) <= '~'))
static void stripCertificateTrailer(char *buffer, int buffer_len) {
- int i;
+
+ int i, is_puny;
// printf("->%s<-\n", buffer);
- for(i=0; i<buffer_len; i++) {
+ for(i = 0; i < buffer_len; i++) {
// printf("%c [%d]\n", buffer[i], buffer[i]);
if((buffer[i] != '.')
@@ -110,21 +111,28 @@ static void stripCertificateTrailer(char *buffer, int buffer_len) {
}
}
- if(i > 0) i--;
-
- while(i > 0) {
- if(!ndpi_isalpha(buffer[i])) {
- buffer[i] = '\0';
- buffer_len = i;
- i--;
- } else
- break;
- }
-
- for(i=buffer_len; i>0; i--) {
- if(buffer[i] == '.') break;
- else if(ndpi_isdigit(buffer[i]))
- buffer[i] = '\0', buffer_len = i;
+ /* check for punycode encoding */
+ is_puny = check_punycode_string(buffer, buffer_len);
+
+ // not a punycode string - need more checks
+ if(is_puny == 0) {
+
+ if(i > 0) i--;
+
+ while(i > 0) {
+ if(!ndpi_isalpha(buffer[i])) {
+ buffer[i] = '\0';
+ buffer_len = i;
+ i--;
+ } else
+ break;
+ }
+
+ for(i = buffer_len; i > 0; i--) {
+ if(buffer[i] == '.') break;
+ else if(ndpi_isdigit(buffer[i]))
+ buffer[i] = '\0', buffer_len = i;
+ }
}
}