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

lidtsvc: coverity fixes

This commit is contained in:
Peter Howkins 2018-04-12 01:38:02 +01:00
parent 91bb9a037a
commit 691dffb076
17 changed files with 52 additions and 20 deletions

View file

@ -28,6 +28,7 @@
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
@ -274,7 +275,7 @@ _SHXbuf::filegen()
{
long i;
// compare all entries to a copy of the first entry
strcpy(filebuf, &bufptr[long(vec[0])]);
snprintf(filebuf, sizeof(filebuf), "%s", &bufptr[long(vec[0])]);
for (i = 1; i < vec.size(); i++)
{

View file

@ -74,6 +74,7 @@ XeCreateContextString(XeString host,
if ((strequal(directory, (XeString)"")) || (directory == NULL)){
if ((strequal(file, (XeString)"")) || (file == NULL)){
Xe_release_str(host);
return((XeString) NULL);
} else {
context_string = XeMalloc (strlen(host) + strlen(file) + 2);

View file

@ -197,6 +197,7 @@ static char * get_tmp_dir (
if (is_dir_usable (dir))
return (dir);
free(dir);
return (NULL);
}

View file

@ -89,6 +89,7 @@ Wire *getpipe(Wire *prevwire)
/* Get file descriptors for pipe */
if (pipe(wire_ptr->fd) < OK) {
SPC_Error(SPC_No_Pipe);
XeFree(wire_ptr);
return(SPC_ERROR);
}
return(wire_ptr);

View file

@ -441,8 +441,10 @@ int exec_proc_local_channel_object(SPC_Channel_Ptr channel)
}
}
if(mempf0(channel, pre_fork)==SPC_ERROR)
if(mempf0(channel, pre_fork)==SPC_ERROR) {
XeFree(dir);
return(SPC_ERROR);
}
/* When using HP NLIO (xj0input) we have a problem. Namely, */
/* the xj0 processs uses signal() to deal with SIGCLD which */
@ -458,8 +460,10 @@ int exec_proc_local_channel_object(SPC_Channel_Ptr channel)
sigemptyset(&oldsigmask);
sigaddset(&newsigmask, SIGCHLD);
if (sigprocmask(SIG_BLOCK, &newsigmask, &oldsigmask) == ERROR)
if (sigprocmask(SIG_BLOCK, &newsigmask, &oldsigmask) == ERROR) {
XeFree(dir);
return(SPC_ERROR);
}
pid = channel->pid = fork();

View file

@ -344,8 +344,10 @@ SPC_Contact_Server(SPC_Connection_Ptr connection)
memcpy(&saddr.sin_addr, remote->h_addr, remote->h_length);
if(connect(connection->sid, (struct sockaddr *)&saddr, sizeof(saddr)) == ERROR) {
SPC_Error(SPC_Bad_Connect,
XeFindShortHost(remote->h_name));
XeString shorthost = XeFindShortHost(remote->h_name);
SPC_Error(SPC_Bad_Connect, shorthost);
XeFree(shorthost);
return(SPC_ERROR);
}

View file

@ -768,8 +768,10 @@ int SPC_Write_Protocol_Request (SPC_Connection_Ptr connection,
envp=va_arg(ap, XeString *);
va_end(ap);
pdata->len=WRITE_APPLICATION_SPAWN(pdata, path, dir, argv, envp);
if(pdata->len == SPC_ERROR)
if(pdata->len == SPC_ERROR) {
SPC_Free_Protocol_Ptr(prot_request);
return(SPC_ERROR);
}
prot_name=(XeString)" <-- APPLICATION_SPAWN";
break;
}
@ -929,6 +931,7 @@ int SPC_Write_Protocol_Request (SPC_Connection_Ptr connection,
if(connection->protocol_version < 3) {
SPC_Error(SPC_Protocol_Version_Error,
3, channel->connection->protocol_version);
SPC_Free_Protocol_Ptr(prot_request);
return(SPC_ERROR);
}
@ -940,6 +943,7 @@ int SPC_Write_Protocol_Request (SPC_Connection_Ptr connection,
if(connection->protocol_version < 3) {
SPC_Error(SPC_Protocol_Version_Error,
3, channel->connection->protocol_version);
SPC_Free_Protocol_Ptr(prot_request);
return(SPC_ERROR);
}
@ -958,6 +962,7 @@ int SPC_Write_Protocol_Request (SPC_Connection_Ptr connection,
buffer = SPC_Decode_Termios(termios_ptr);
pdata->len=WRITE_TERMIOS(pdata, connector, side, buffer);
prot_name=(XeString)" <-- CHANNEL_TERMIOS";
free(buffer);
break;
}
@ -965,6 +970,7 @@ int SPC_Write_Protocol_Request (SPC_Connection_Ptr connection,
if(connection->protocol_version < 3) {
SPC_Error(SPC_Protocol_Version_Error,
3, channel->connection->protocol_version);
SPC_Free_Protocol_Ptr(prot_request);
return(SPC_ERROR);
}
@ -1229,8 +1235,10 @@ char **SPC_Get_Multi_Packet(SPC_Connection_Ptr connection,
if(localprot)
SPC_Free_Protocol_Ptr(localprot);
prot=SPC_Filter_Connection(connection, NULL, request, TRUE);
if(prot==SPC_ERROR)
if(prot==SPC_ERROR) {
free(out);
return(SPC_ERROR);
}
print_protocol_request(name, prot);
localprot=prot;
bufptr=PDRP(prot->dataptr);
@ -1442,6 +1450,8 @@ sscan_application_data(XeString buf,
*envp=sscan_counted_string(bufptr, &bufptr);
if(*envp==SPC_ERROR)
return(SPC_ERROR);
return(TRUE);
}
/*----------------------------------------------------------------------+*/
@ -1657,7 +1667,7 @@ int SPC_Query_Logfile(SPC_Channel_Ptr channel)
READ_LOGFILE_REPLY(prot->dataptr, &channel->logfile, &junk1, &junk2);
if (junk1) XeFree(junk1);
if (junk1) XeFree(junk2);
if (junk2) XeFree(junk2);
SPC_Free_Protocol_Ptr(prot);
return (TRUE);
@ -1811,6 +1821,7 @@ SPC_Validate_User(XeString hostname,
tt_free (path);
XeFree(connection_hostname);
if (logfile) XeFree(logfile);
close(open_status);
return(SPC_ERROR);
}

View file

@ -1598,6 +1598,7 @@ CreateInvocationRecord(
SET_INV_ERROR(invp->state);
SET_INV_CANCEL(invp->state);
close(fd);
return invp;
}

View file

@ -446,7 +446,7 @@ _DtActValidateFieldValue( long bit, char *value, char *actName, char *filename)
val, _DtACTION_ARG_MODE);
_DtSimpleError(DtProgName,DtError, NULL, "%s", buf);
free(val);
buf = malloc(_DtAct_MAX_BUF_SIZE);
free(buf);
return NULL;
}
break; /* valid value */
@ -1027,7 +1027,7 @@ _DtActionConverter(DtDtsDbField * fields,
sprintf (buf, missingName, _DtACTION_NAME, fileName);
_DtSimpleError(DtProgName,DtError, NULL, "%s", buf);
XtFree(fileName);
if (buf) XtFree(buf);
XtFree(buf);
_DtSvcProcessUnlock();
return(True);
}

View file

@ -1393,7 +1393,7 @@ static void
_DtActMMGetTtMsgInfo(DtDtsMMRecord *actRecp, ActionPtr actp)
{
char argNname[ sizeof(_DtACTION_TTN_ARG) /* space for prefix */
+ 3 /* enough space for three decimal digits */
+ 9 /* enough space for three decimal digits */
+ sizeof(_DtACTION_TTN_REP_TYPE)]; /* space for longest suffix */
int i;
char *s;
@ -2165,6 +2165,7 @@ _DtActionFindDBEntry( ActionRequest *reqp,
if ( reqp )
SET_TOO_MANY_MAPS(reqp->mask);
_DtSvcProcessUnlock();
free(mapto);
return NULL;
}
}

View file

@ -484,6 +484,7 @@ dndFileContentsToSelectionValue(
buf = (void *)XtMalloc(bufLen + 1);
bytesRead = read(fd, buf, bufLen);
close(fd);
if (bytesRead == -1 || bytesRead != bufLen) {
XtFree((char *)buf);

View file

@ -155,7 +155,8 @@ extern int cde_da_compare(DtDtsMMRecord **entry1, DtDtsMMRecord **entry2);
extern int cde_dc_field_compare(DtDtsMMField **entry1, DtDtsMMField **entry2);
_DtDtsClear()
void
_DtDtsClear(void)
{
_DtSvcProcessLock();
dtdts_path_pattern = 0;

View file

@ -69,6 +69,7 @@ typedef int (*genfunc)(const void *, const void *);
static DtDtsDbDatabase **db_list;
static int num_db = 0;
void
_DtDtsDbPrintFields(DtDtsDbRecord *rec_ptr, FILE *fd)
{
int fld;
@ -84,6 +85,7 @@ _DtDtsDbPrintFields(DtDtsDbRecord *rec_ptr, FILE *fd)
}
}
void
_DtDtsDbPrintRecords(DtDtsDbDatabase *db_ptr, FILE *fd)
{
int rec;

View file

@ -691,6 +691,7 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile)
_DtSimpleError(
DtProgName, DtError, NULL,
(char*) tmpfile, NULL);
free(tmpfile);
return(0);
}

View file

@ -1293,7 +1293,7 @@ _DtWsmSetBackdropSearchPath (
if (postDtEnvironmentString != postDtEnvironmentStringBuf)
{
if (postDtEnvironmentString) XtFree(postDtEnvironmentString);
XtFree(postDtEnvironmentString);
postDtEnvironmentString = NULL;
}

View file

@ -55,6 +55,9 @@ _DtPrintDefaultError(
{
_DtPrintDefaultErrorSafe(dpy, event, msg, BUFSIZ);
/* XXX retval? */
/* COV: 87468 nothing actually checks this return value */
return(1);
}
#define _DTP_STRNCAT(s1, s2, nb, ec) \

View file

@ -33,6 +33,7 @@
*
*****************************************************************************/
#include <stdio.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -322,8 +323,8 @@ GetDisplayName (
/*
* Create the display name and append it to the current path.
*/
(void)strcpy(hostName, display->display_name);
(void)strcpy(displayName, display->display_name);
snprintf(hostName, sizeof(hostName), "%s", display->display_name);
snprintf(displayName, sizeof(displayName), "%s", display->display_name);
/*
* If this is run to unix or local get the host name - otherwise