From: Jon Trulson Date: Fri, 26 Dec 2014 22:59:52 +0000 (-0700) Subject: DtTerm: Coverity (memory corruption, moderate) X-Git-Tag: 2.2.3~79 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=50de34a9331a372a336e4299a37ec8c42e1f8690;p=oweals%2Fcde.git DtTerm: Coverity (memory corruption, moderate) --- 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: