From 50de34a9331a372a336e4299a37ec8c42e1f8690 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Fri, 26 Dec 2014 15:59:52 -0700 Subject: [PATCH] DtTerm: Coverity (memory corruption, moderate) --- cde/lib/DtTerm/TermPrim/TermPrimDebug.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cde/lib/DtTerm/TermPrim/TermPrimDebug.c b/cde/lib/DtTerm/TermPrim/TermPrimDebug.c index c79d8a10..89a9e22e 100644 --- a/cde/lib/DtTerm/TermPrim/TermPrimDebug.c +++ b/cde/lib/DtTerm/TermPrim/TermPrimDebug.c @@ -444,15 +444,15 @@ enumToName { int i1; char buffer[BUFSIZ]; - static char *retBuffer = (char *) 0; + static char *retBuffer = NULL; for (i1 = 0; list[i1].string; i1++) { if (list[i1].value == value) { return(list[i1].string); } } - (void) sprintf(buffer, "Unknown Value %d", value); - retBuffer = realloc(retBuffer, strlen(buffer)); + snprintf(buffer, BUFSIZ, "Unknown Value %d", value); + retBuffer = realloc(retBuffer, strlen(buffer) + 1); (void) strcpy(retBuffer, buffer); return(retBuffer); } @@ -467,14 +467,14 @@ _DtTermPrimDebugDumpEvent { _DtTermProcessLock(); (void) fprintf(f, ">> widget: name=\"%s\" widget=0x%lx window=0x%lx\n", - XtName(w), w, XtWindow(w)); + XtName(w), (long)w, XtWindow(w)); (void) fprintf(f, ">> event {\n"); (void) fprintf(f, ">> type=%s;\n", enumToName(eventTypes, ev->xany.type)); (void) fprintf(f, ">> serial=%lu\n", ev->xany.serial); (void) fprintf(f, ">> send_event=%s\n", enumToName(boolTypes, ev->xany.send_event)); - (void) fprintf(f, ">> display=0x%lx\n", ev->xany.display); + (void) fprintf(f, ">> display=0x%lx\n", (long)ev->xany.display); (void) fprintf(f, ">> window=0x%lx\n", ev->xany.window); switch (ev->type) { case EnterNotify: -- 2.25.1