X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fsession.c;h=936bb4dff8060a6f48a0c8b8bf86204c611654fd;hb=56f9ef4581d567248b6f83a3b15f39a0aca42895;hp=11f535b3f87a9d543f91a460a234c63cd068cda0;hpb=6ea1d50ab6571551e1d0379940349911956c97ee;p=src%2Fapp-framework-binder.git diff --git a/src/session.c b/src/session.c index 11f535b3..936bb4df 100644 --- a/src/session.c +++ b/src/session.c @@ -243,7 +243,7 @@ void ctxClientClose (struct AFB_clientCtx *clientCtx) } // Sample Generic Ping Debug API -int ctxTokenCheck (struct AFB_clientCtx *clientCtx, const char *token) +int ctxTokenCheckLen (struct AFB_clientCtx *clientCtx, const char *token, size_t length) { assert(clientCtx != NULL); assert(token != NULL); @@ -252,13 +252,20 @@ int ctxTokenCheck (struct AFB_clientCtx *clientCtx, const char *token) if (ctxStoreTooOld (clientCtx, NOW)) return 0; - if (!clientCtx->token[0] || 0 == strcmp (token, clientCtx->token)) { - clientCtx->created = 1; /* creates by default */ - return 1; - } + if (clientCtx->token[0] && (length >= sizeof(clientCtx->token) || strncmp (token, clientCtx->token, length) || clientCtx->token[length])) + return 0; + + clientCtx->created = 1; /* creates by default */ + return 1; +} + +// Sample Generic Ping Debug API +int ctxTokenCheck (struct AFB_clientCtx *clientCtx, const char *token) +{ + assert(clientCtx != NULL); + assert(token != NULL); - // Token is not valid let move level of assurance to zero and free attached client handle - return 0; + return ctxTokenCheckLen(clientCtx, token, strlen(token)); } // generate a new token and update client context