From 6c72070fd459ec8b019691bce1eecf62e4ef5537 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 2 May 2013 08:15:53 +0800 Subject: [PATCH] trac 29 convert more snprintf stowaways Signed-off-by: Andy Green --- test-server/test-server.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test-server/test-server.c b/test-server/test-server.c index 8acf62a..b4352f7 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -732,8 +732,18 @@ int main(int argc, char **argv) info.ssl_cert_filepath = NULL; info.ssl_private_key_filepath = NULL; } else { - snprintf(cert_path, sizeof(cert_path), "%s/libwebsockets-test-server.pem", resource_path); - snprintf(key_path, sizeof(cert_path), "%s/libwebsockets-test-server.key.pem", resource_path); + if (strlen(resource_path) > sizeof(cert_path) - 32) { + lwsl_err("resource path too long\n"); + return -1; + } + sprintf(cert_path, "%s/libwebsockets-test-server.pem", + resource_path); + if (strlen(resource_path) > sizeof(key_path) - 32) { + lwsl_err("resource path too long\n"); + return -1; + } + sprintf(key_path, "%s/libwebsockets-test-server.key.pem", + resource_path); info.ssl_cert_filepath = cert_path; info.ssl_private_key_filepath = key_path; -- 2.7.4