summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Friloux <kuri@friloux.me>2014-04-19 23:48:05 +0200
committerGuillaume Friloux <kuri@friloux.me>2014-04-19 23:48:05 +0200
commit5d1e9e725eecefab1e8b7a8e0baec38d80db5cd2 (patch)
tree71599b7bf44a73b04f3fde3650ca4e5427e3c014
parent6afedf5eab36225741634221fbf7754226fea920 (diff)
Add support for finger apps not sending \n or even \r
-rw-r--r--src/lib/fingered_event.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/lib/fingered_event.c b/src/lib/fingered_event.c
index 1953c21..bece845 100644
--- a/src/lib/fingered_event.c
+++ b/src/lib/fingered_event.c
@@ -67,8 +67,10 @@ fingered_event_data(void *data,
67 Fingered *f; 67 Fingered *f;
68 Fingered_User *fu; 68 Fingered_User *fu;
69 char *n, 69 char *n,
70 *r,
70 *p; 71 *p;
71 char fmt[128]; 72 char fmt[128];
73 size_t l;
72 74
73 DBG("data[%p] ev[%p]", data, ev); 75 DBG("data[%p] ev[%p]", data, ev);
74 76
@@ -84,16 +86,23 @@ fingered_event_data(void *data,
84 printf(fmt, event->data); 86 printf(fmt, event->data);
85 87
86 n = memchr(event->data, '\n', event->size); 88 n = memchr(event->data, '\n', event->size);
87 if ((!n) || (event->size == 1) || (*(n-1) != '\r')) 89 if (!n)
88 { 90 {
89 ERR("Invalid data received from %s", 91 l = event->size;
90 ecore_con_client_ip_get(event->client)); 92 goto check_user;
91 ecore_con_client_del(event->client); 93 }
92 return EINA_TRUE; 94
95 r = memchr(event->data, '\r', event->size);
96 if (!r)
97 {
98 l = n - (char *)event->data;
99 goto check_user;
93 } 100 }
94 101
102 l = r - (char *)event->data;
95 103
96 for (p = event->data; (n - p) > 1; p++) 104check_user:
105 for (p = event->data; (size_t)(p - (char *)event->data) < l; p++)
97 { 106 {
98 if (isalnum(*p)) 107 if (isalnum(*p))
99 continue; 108 continue;
@@ -102,8 +111,7 @@ fingered_event_data(void *data,
102 return EINA_TRUE; 111 return EINA_TRUE;
103 } 112 }
104 113
105 fu = fingered_user_new(event->data, n - (char *)event->data - 1, 114 fu = fingered_user_new(event->data, l, event->client);
106 event->client);
107 if (!fu) 115 if (!fu)
108 return EINA_TRUE; 116 return EINA_TRUE;
109 117