From 16348aaccd74281f38a74b40a456984ca002e5cb Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Fri, 27 Jul 2012 02:06:58 -0400 Subject: [PATCH] replace strlen() call with strnlen() and MAX_SPA_ENCODED_MSG_SIZE bound --- lib/fko_encode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/fko_encode.c b/lib/fko_encode.c index 2adb42ff..5a28b6ec 100644 --- a/lib/fko_encode.c +++ b/lib/fko_encode.c @@ -41,9 +41,12 @@ static int append_b64(char* tbuf, char *str) { - int len = strlen(str); + int len = strnlen(str, MAX_SPA_ENCODED_MSG_SIZE); char *bs; + if(len >= MAX_SPA_ENCODED_MSG_SIZE) + return(FKO_ERROR_INVALID_DATA); + bs = malloc(((len/3)*4)+8); if(bs == NULL) return(FKO_ERROR_MEMORY_ALLOCATION);