1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dthelp: Further coverity fixes

This commit is contained in:
Peter Howkins 2018-04-30 04:11:44 +01:00
parent c936a8c065
commit 48b97a4c41
15 changed files with 76 additions and 55 deletions

View file

@ -305,7 +305,6 @@ CreateVolumeLink (
char *title = NULL;
char *charSet = (char *) DefCharSet;
char *abstract = NULL;
char *filename = NULL;
char *pathName = NULL;
VolumeHandle volume = NULL;
@ -359,8 +358,6 @@ CreateVolumeLink (
if (title)
free ((void *) title);
if (filename)
free ((void *) filename);
return result;
}

View file

@ -218,10 +218,11 @@ int _DtHPrPrintManPage(
}
/* Alloc max shell command line len */
printCommand = malloc(MAX_COMMAND_LENGTH*sizeof(char));
printCommand = malloc(MAX_COMMAND_LENGTH);
if (printCommand == NULL)
{
fprintf(stderr, _DTGETMESSAGE(PMSET,5,
"%s: Error: memory allocation failed\n"),
options->programName );
@ -231,7 +232,7 @@ int _DtHPrPrintManPage(
/** generate the command **/
snprintf(cmdFormat, sizeof(cmdFormat), "%s %s", /* man */
options->manCommand, options->manArgs);
snprintf(printCommand, sizeof(MAX_COMMAND_LENGTH*sizeof(char)), cmdFormat,
snprintf(printCommand, MAX_COMMAND_LENGTH, cmdFormat,
options->manPage); /* man */
retval = _DtHPrGenFileOrPrint(options,options->manPage,printCommand);

View file

@ -2273,13 +2273,11 @@ int ProcessTopics(
/* if processing subtopics, start processing at the top */
if ( processSubTopics )
{
char * name = NULL;
int offset;
/* get the top topic of the volume */
ret = _DtHelpCeGetTopTopicId(state->volHandle, &state->currentLocId);
if (ret != True) state->currentLocId = strdup("_HOMETOPIC");
if(name) free(name);
}
else
{ /* otherwise, process only where needed */
@ -2413,7 +2411,7 @@ int DoHelpTopicsProcessing(
char * buf;
char * start;
char * next;
char * pgbrkFile;
char * pgbrkFile = NULL;
char * partFiles[NUMPARTS];
Boolean validFile = False;
@ -2514,7 +2512,10 @@ cleanup:
unlink(partFiles[i]);
free(partFiles[i]);
}
if(pgbrkFile) {
unlink(pgbrkFile);
}
/* NOTE: should free Toc here if interested in no leaks */

View file

@ -166,13 +166,16 @@ void CloseHelpCB (
pTemp = pCacheListHead;
/* Search our Cache List for the closed help dialog */
while ((pTemp->helpDialog != helpDialog) && (pTemp != NULL))
while ((pTemp != NULL) && (pTemp->helpDialog != helpDialog))
pTemp = pTemp->pNext;
if (pTemp == NULL)
if (pTemp == NULL) {
/* ERROR */
printf("We did not find our help dialog widget in the cache list??? /n");
/* TODO what error handling here? */
return;
}
/* Un Map and Clean up the help widget */
XtUnmanageChild(helpDialog);

View file

@ -75,7 +75,7 @@ int main(argc, argv)
fprintf(stderr, "**** Specify interface file ****\n") ;
exit(TRUE) ;
}
strncpy(iffile, argv[1], IFLEN) ;
snprintf(iffile, sizeof(iffile), "%s", argv[1]) ;
initialize() ;
while (TRUE) {
m_token = scan() ;

View file

@ -126,7 +126,7 @@ if ( *(m_argv[0]) == '/' )
else
{
/* not fully specified, check each component of path for ourself */
strcpy(patbuf, getenv("PATH"));
snprintf(patbuf, sizeof(patbuf), "%s", getenv("PATH"));
path = patbuf;
cp = path;
@ -538,8 +538,10 @@ M_WCHAR *parent, *gentity, *gposition, *ghyperlink, *glinktype, *gdescription;
{
unsigned char etype, wheredef;
char *mb_content, *ssi, id[32];
static M_WCHAR empty = M_EOS;
static M_WCHAR empty[1];
char *leftright;
empty[0] = M_EOS;
/* handle graphic specific code */
/* initialize some stuff first:
@ -627,7 +629,7 @@ if (gentity)
gentity);
}
}
if (!f_content) f_content = ∅
if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
sprintf(id, "%s%d", sdlReservedName, NextId());
@ -718,7 +720,7 @@ int count, metaCount;
char *item_id;
char label_id[SDLNAMESIZ+10];
int listtype;
char *type;
char *type = NULL;
char *loose;
char *first;
LOGICAL isBullet, isLoose, isFirst;
@ -824,9 +826,10 @@ if (listtype == ORDER)
switch (lastlist->lastlist->order)
{
case UROMAN:
strcpy(orderString, ROMAN100[count / 100]);
strcat(orderString, ROMAN10[(count / 10) % 10]);
strcat(orderString, ROMAN0[count % 10]);
snprintf(orderString, sizeof(orderString), "%s%s%s",
ROMAN100[count / 100],
ROMAN10[(count / 10) % 10],
ROMAN0[count % 10]);
type = romanString;
break;
case UALPHA:
@ -848,9 +851,10 @@ if (listtype == ORDER)
type = arabicString;
break;
case LROMAN:
strcpy(orderString, roman100[count / 100]);
strcat(orderString, roman10[(count / 10) % 10]);
strcat(orderString, roman0[count % 10]);
snprintf(orderString, sizeof(orderString), "%s%s%s",
roman100[count / 100],
roman10[(count / 10) % 10],
roman0[count % 10]);
type = romanString;
break;
case LALPHA:
@ -868,7 +872,7 @@ if (listtype == ORDER)
"%s%s-%s\">\n<P>%s%c",
first,
loose,
type,
type ? type : "",
orderString,
lastlist->lastlist->punct == DOTPUNCT ? '.' : ')' );
if (id)
@ -1508,17 +1512,19 @@ _DtXlateDb myDb = NULL;
char myPlatform[_DtPLATFORM_MAX_LEN+1];
char myLocale[256]; /* arbitrarily large */
char *locale;
char *lang;
char *charset;
char *lang = NULL;
char *charset = NULL;
int execVer;
int compVer;
int isStd;
strcpy(myLocale, pLang);
if (*pCharset)
{
strcat(myLocale, ".");
strcat(myLocale, pCharset);
snprintf(myLocale, sizeof(myLocale), "%s.%s", pLang, pCharset);
}
else
{
snprintf(myLocale, sizeof(myLocale), "%s", pLang);
}
if ((_DtLcxOpenAllDbs(&myDb) != 0) ||
@ -1601,7 +1607,6 @@ else
if (*lang)
{
strcpy(pLang, lang);
mb_free(&lang);
}
else
strcpy(pLang, cString);
@ -1609,13 +1614,16 @@ else
if (*charset)
{
strcpy(pCharset, charset);
mb_free(&charset);
free(charset);
}
else
strcpy(pCharset, isoString);
}
mb_free(&lang);
mb_free(&charset);
free(charset);
_DtLcxCloseDb(&myDb);
}
@ -1773,9 +1781,9 @@ if (!charset)
if (dotPtr)
*dotPtr = 0;
strcpy(stdLang, locale);
snprintf(stdLang, sizeof(stdLang), "%s", locale);
if (charset)
strcpy(stdCharset, charset);
snprintf(stdCharset, sizeof(stdCharset), "%s", charset);
SetStdLocale(stdLang, stdCharset);
if (*stdCharset)
@ -2049,10 +2057,12 @@ if (file)
sprintf(snb_id, "%s%d", sdlReservedName, NextId());
{
static M_WCHAR empty = M_EOS;
static M_WCHAR empty[1];
char *mb_content;
empty[0] = M_EOS;
if (!f_content) f_content = &empty;
if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
AddToSNB(snb_id, mb_content);
@ -2763,8 +2773,8 @@ if (*icon)
fputs("CLASS=\"ICON\" SSI=\"NCW-ICON\">", outfile);
fputs("</REFITEM>\n</SNREF></HEAD>\n", outfile);
AddToSNB(id, icon);
m_free(icon, "icon name");
}
m_free(icon, "icon name");
}
@ -2838,8 +2848,7 @@ while (thispath)
else
try = mb_realloc(try, tryleng);
}
strcpy(try, thispath->directory);
strcpy(try + pathleng, mb_inputname);
sprintf(try, "%s%s", thispath->directory, mb_inputname);
tossfile = open(try, O_RDONLY);
if (tossfile >= 0) break;
thispath = thispath->next;

View file

@ -516,15 +516,15 @@ static char ident6[]="@(#) (c) Copyright 1993, 1994 Unix System Labs, Inc., a su
if (termp - term > 1 && *(termp-1) == ' ') {
*(termp-1) = M_EOS;
}
if (!(lastTermId = (int) m_lookfortrie(term, &gtree)))
if (!(lastTermId = (int)(intptr_t) m_lookfortrie(term, &gtree)))
{
lastTermId = NextId();
m_ntrtrie(term, &gtree, (void *) -lastTermId);
m_ntrtrie(term, &gtree, (void *)(intptr_t) -lastTermId);
}
else
if (lastTermId > 0)
{
if (!m_resettrie(&gtree, term, (void *) -lastTermId))
if (!m_resettrie(&gtree, term, (void *)(intptr_t) -lastTermId))
{
m_error("Internal error. Can't reset glossary trie") ;
m_exit(TRUE) ;
@ -685,7 +685,7 @@ static char ident6[]="@(#) (c) Copyright 1993, 1994 Unix System Labs, Inc., a su
m_error("Program error: exceeded chapstring") ;
m_exit(TRUE) ;
}
sprintf(chapstring, sizeof(chapstring), "%s", string) ;
snprintf(chapstring, sizeof(chapstring), "%s", string) ;
fputs("\nGlossary\n", stderr) ;
glossary = TRUE ;
fprintf(outfile, "<HEAD SSI=\"CHAPHEAD\">%s</HEAD>\n", string);
@ -778,9 +778,10 @@ static char ident6[]="@(#) (c) Copyright 1993, 1994 Unix System Labs, Inc., a su
{
char *mb_content, snb_id[32];
char buffer[BIGBUF];
static M_WCHAR empty = M_EOS;
static M_WCHAR empty[1];
empty[0] = M_EOS;
if (!f_content) f_content = &empty;
if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
sprintf(snb_id, "%s%d", sdlReservedName, NextId());

View file

@ -198,7 +198,7 @@ if (bufflen == 1)
exLineNum++;
if (special[index])
{
strcpy(exbuff, special[index]);
snprintf(exbuff, sizeof(exbuff), "%s", special[index]);
bufflen = strlen(exbuff);
}
}
@ -230,7 +230,7 @@ if (bufflen == 1)
index = (unsigned char) imbuff[0];
if (special[index])
{
strcpy(imbuff, special[index]);
snprintf(imbuff, sizeof(imbuff), "%s", special[index]);
bufflen = strlen(imbuff);
}
mb_strcode(imbuff, outfile);

View file

@ -72,8 +72,7 @@ void entout(fname)
int nameindex ;
LOGICAL start ;
strncpy(efilename, fname, ENTFILENAME) ;
strncpy(&efilename[strlen(efilename)], ".h", 2) ;
snprintf(efilename, sizeof(efilename), "%s.h", fname) ;
m_openchk(&entfile, efilename, "w") ;
fprintf(entfile, "#include \"entdef.h\"\n") ;

View file

@ -210,7 +210,11 @@ SEARCH *searchp;
char *mb_entcontent;
mb_entcontent = MakeMByteString(entcontent);
if (!*mb_entcontent) return NULL; /* null file name, don't open a directory */
if (!*mb_entcontent) /* null file name, don't open a directory */
{
m_free(mb_entcontent, "multi-byte string");
return NULL;
}
open = fopen(mb_entcontent, "r");
if (open)
@ -301,7 +305,9 @@ void m_signmsg(p)
if (q = strstr(p, VERSION)) {
pCopy = strdup(p);
q = strstr(pCopy, VERSION);
if(q) {
*q = M_EOS;
}
m_errline(pCopy);
free(pCopy);
return;

View file

@ -870,9 +870,10 @@ static char ident6[]="@(#) (c) Copyright 1993, 1994 Unix System Labs, Inc., a su
{
char *mb_content, snb_id[32];
char buffer[BIGBUF];
static M_WCHAR empty = M_EOS;
static M_WCHAR empty[1];
empty[0] = M_EOS;
if (!f_content) f_content = &empty;
if (!f_content) f_content = empty;
mb_content = MakeMByteString(f_content);
sprintf(snb_id, "%s%d", sdlReservedName, NextId());

View file

@ -153,6 +153,9 @@ FILE *tex;
strcpy(helpext, ".xrh");
tex = fopen(helpbase, "w");
if (! tex) {
return;
}
fprintf(tex, "\\gobble\001%s\002%%\n", m_signon);
fputs("% Generated Cross-Reference Macros (for a particular document)\n", tex);
if (! xtree.data) {

View file

@ -93,7 +93,6 @@ void m_free(block, msg)
#if defined(MSDOS)
if (m_heapchk) m_heapdump() ;
#endif
free(block) ;
if (m_malftrace) {
#if defined(hpux) || defined(_AIX) || defined(sun) || defined(USL) || defined(__uxp__)
snprintf(buffer, 32, "%5x:%5x",
@ -107,6 +106,7 @@ void m_free(block, msg)
m_trace(msg) ;
m_trace("\n") ;
}
free(block) ;
#if defined(MSDOS)
if (m_heapchk) m_heapdump() ;
#endif

View file

@ -483,7 +483,7 @@ char *partype(n)
void srefout(M_NOPAR)
{
LOGICAL first = TRUE ;
int *mapbysref ;
int *mapbysref = NULL;
SREFSTRUCT *srefp ;
SREFDATA *data ;
int count = 0 ;

View file

@ -1563,7 +1563,7 @@ static void MarkUsedStyle(level, class, ssi)
#endif
{
ElementPtr pThis;
M_WCHAR *rlevel, *rclass, *rssi;
M_WCHAR *rlevel = NULL, *rclass = NULL, *rssi = NULL;
LOGICAL *pBeenUsed;
pThis = pTossChain;