libtt: Resolve coverity warnings

This commit is contained in:
Peter Howkins
2018-04-11 19:31:03 +01:00
parent db88cb0d13
commit 30ad8e35e5
11 changed files with 50 additions and 38 deletions

View File

@@ -159,7 +159,7 @@ _unlink_datfile(isfname)
{
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makedat_isfname(namebuf);
(void)unlink(namebuf);
@@ -172,7 +172,7 @@ _unlink_indfile(isfname)
{
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makeind_isfname(namebuf);
(void)unlink(namebuf);
@@ -185,7 +185,7 @@ _unlink_varfile(isfname)
{
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makevar_isfname(namebuf);
(void)unlink(namebuf);

View File

@@ -197,8 +197,11 @@ _isfcb_open(isfname, errcode)
* Open the UNIX file for .rec file.
*/
if ((dat_fd = _open_datfile (isfname, &rdonly)) == -1 || errno == EMFILE) {
_amseterrcode(errcode, errno);
return (NULL);
_amseterrcode(errcode, errno);
if(dat_fd != -1) {
close(dat_fd);
}
return (NULL);
}
/*
@@ -640,7 +643,7 @@ _create_datfile(isfname)
int fd;
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makedat_isfname(namebuf);
fd = open (namebuf, O_CREAT | O_EXCL | O_RDWR, 0666);
@@ -663,7 +666,7 @@ _create_indfile(isfname)
int fd;
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makeind_isfname(namebuf);
fd = open (namebuf, O_CREAT | O_EXCL | O_RDWR, 0666);
@@ -686,7 +689,7 @@ _create_varfile(isfname)
int fd;
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makevar_isfname(namebuf);
fd = open (namebuf, O_CREAT | O_EXCL | O_RDWR, 0666);
@@ -709,7 +712,7 @@ _remove_datfile(isfname)
{
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makedat_isfname(namebuf);
(void) unlink(namebuf);
@@ -727,7 +730,7 @@ _remove_indfile(isfname)
{
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makeind_isfname(namebuf);
(void) unlink(namebuf);
@@ -745,7 +748,7 @@ _remove_varfile(isfname)
{
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makevar_isfname(namebuf);
(void) unlink(namebuf);
@@ -766,7 +769,7 @@ _open_datfile(isfname, rdonly)
char namebuf[MAXPATHLEN];
int ret;
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makedat_isfname(namebuf);
if ((ret = open (namebuf, O_RDWR)) != -1) {
@@ -797,7 +800,7 @@ _open_indfile(isfname, rdonly)
int fd;
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makeind_isfname(namebuf);
fd = open (namebuf, (rdonly==TRUE)?O_RDONLY:O_RDWR);
@@ -821,7 +824,7 @@ _open_varfile(isfname, rdonly)
int fd;
char namebuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
_makevar_isfname(namebuf);
fd = open (namebuf, (rdonly==TRUE)?O_RDONLY:O_RDWR);
@@ -867,7 +870,7 @@ _open2_indfile(fcb)
if (fcb->indfd != -1)
return (ISOK);
(void) strcpy(namebuf, fcb->isfname);
snprintf(namebuf, sizeof(namebuf), "%s", fcb->isfname);
_makeind_isfname(namebuf);
(void)fstat(fcb->datfd, &buf);

View File

@@ -42,8 +42,7 @@ isgarbage(char * isfname)
struct stat statbuf;
int count = 0,i;
(void)strcpy(isfname2, isfname);
(void)strcat(isfname2, "~");
snprintf(isfname2, sizeof(isfname2), "%s~", isfname);
if ((isfd = isopen(isfname, ISEXCLLOCK + ISINPUT)) == ISERROR) {
goto ERROR;

View File

@@ -130,7 +130,7 @@ isrename(oldname, newname)
* still thinks that the file exists for a few seconds.
*/
(void)strcpy(datfname, oldname);
snprintf(datfname, sizeof(datfname), "%s", oldname);
_makedat_isfname(datfname);
(void)unlink(datfname);
@@ -218,16 +218,16 @@ _rename_datfile(isfname, newname)
char namebuf[MAXPATHLEN];
char newbuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
(void) strcpy(newbuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
snprintf(newbuf, sizeof(newbuf), "%s", isfname);
/*
* Replace the last element of the old path with newname.
*/
_removelast(newbuf);
if (strcmp(newbuf, "/") != 0)
(void) strcat(newbuf, "/");
(void)strcat(newbuf, newname);
snprintf(newbuf, sizeof(newbuf), "%s/", newbuf);
snprintf(newbuf, sizeof(newbuf), "%s%s", newbuf, newname);
_makedat_isfname(namebuf);
_makedat_isfname(newbuf);
@@ -243,16 +243,16 @@ _rename_indfile(isfname, newname)
char namebuf[MAXPATHLEN];
char newbuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
(void) strcpy(newbuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
snprintf(newbuf, sizeof(newbuf), "%s", isfname);
/*
* Replace the last element of the old path with newname.
*/
_removelast(newbuf);
if (strcmp(newbuf, "/") != 0)
(void) strcat(newbuf, "/");
(void)strcat(newbuf, newname);
snprintf(newbuf, sizeof(newbuf), "%s/", newbuf);
snprintf(newbuf, sizeof(newbuf), "%s%s", newbuf, newname);
_makeind_isfname(namebuf);
_makeind_isfname(newbuf);
@@ -268,16 +268,16 @@ _rename_varfile(isfname, newname)
char namebuf[MAXPATHLEN];
char newbuf[MAXPATHLEN];
(void) strcpy(namebuf, isfname);
(void) strcpy(newbuf, isfname);
snprintf(namebuf, sizeof(namebuf), "%s", isfname);
snprintf(newbuf, sizeof(newbuf), "%s", isfname);
/*
* Replace the last element of the old path with newname.
*/
_removelast(newbuf);
if (strcmp(newbuf, "/") != 0)
(void) strcat(newbuf, "/");
(void)strcat(newbuf, newname);
snprintf(newbuf, sizeof(newbuf), "%s/", newbuf);
snprintf(newbuf, sizeof(newbuf), "%s%s", newbuf, newname);
_makevar_isfname(namebuf);
_makevar_isfname(newbuf);

View File

@@ -591,8 +591,7 @@ _amstart(isfhandle, record, reclen, readmode,
_amseterrcode(errcode, ISOK);
/* Clean-up work. */
if (newcrp != NULL)
free(newcrp);
free(newcrp);
_isdisk_commit(); /* This will only check
* that we unfixed all fixed