From 03f37c0cdc05bde0bc5c3c5c7bb0bd0aaed4a1e5 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 24 Nov 2015 17:17:17 +0100 Subject: [PATCH] tesseractmain: Fix unterminated string Coverity bug report: CID 1270421 "Buffer not null terminated". Signed-off-by: Stefan Weil --- api/tesseractmain.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/tesseractmain.cpp b/api/tesseractmain.cpp index f267d6c84..fd77dd844 100644 --- a/api/tesseractmain.cpp +++ b/api/tesseractmain.cpp @@ -186,10 +186,11 @@ int main(int argc, char **argv) { exit(1); } - char opt1[255], opt2[255]; + char opt1[256], opt2[255]; for (arg = 0; arg < argc; arg++) { if (strcmp(argv[arg], "-c") == 0 && arg + 1 < argc) { strncpy(opt1, argv[arg + 1], 255); + opt1[255] = '\0'; char *p = strchr(opt1, '='); if (!p) { fprintf(stderr, "Missing = in configvar assignment\n");