tesseractmain: Fix unterminated string

Coverity bug report: CID 1270421 "Buffer not null terminated".

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2015-11-24 17:17:17 +01:00 committed by Zdenko Podobný
parent af9212c459
commit 8c4b027292

View File

@ -186,10 +186,11 @@ int main(int argc, char **argv) {
exit(1); exit(1);
} }
char opt1[255], opt2[255]; char opt1[256], opt2[255];
for (arg = 0; arg < argc; arg++) { for (arg = 0; arg < argc; arg++) {
if (strcmp(argv[arg], "-c") == 0 && arg + 1 < argc) { if (strcmp(argv[arg], "-c") == 0 && arg + 1 < argc) {
strncpy(opt1, argv[arg + 1], 255); strncpy(opt1, argv[arg + 1], 255);
opt1[255] = '\0';
char *p = strchr(opt1, '='); char *p = strchr(opt1, '=');
if (!p) { if (!p) {
fprintf(stderr, "Missing = in configvar assignment\n"); fprintf(stderr, "Missing = in configvar assignment\n");