summaryrefslogtreecommitdiff
path: root/exrecover.c
diff options
context:
space:
mode:
authorThomas Ulmer <thomasmulmer02@gmail.com>2026-06-23 21:34:41 -0700
committerThomas Ulmer <thomasmulmer02@gmail.com>2026-06-23 21:34:41 -0700
commit874d317334fae1ddce316f9b6f4d0ce4e434bf52 (patch)
tree929f924d3c3696d3aa9917aca0e7048bbe3e93e8 /exrecover.c
parent15bd7946cc838a3151c357e4b0bc1ab85eecda62 (diff)
heirloom vi fixes from arch AUR
Diffstat (limited to 'exrecover.c')
-rw-r--r--exrecover.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/exrecover.c b/exrecover.c
index 17ba06f..c9a45a8 100644
--- a/exrecover.c
+++ b/exrecover.c
@@ -98,7 +98,8 @@ static char sccsid[] UNUSED = "@(#)exrecover.c 1.23 (gritter) 12/25/06";
#define xstderr (int*)0
typedef int xFILE;
extern void perror(const char *);
-extern int vsprintf(char *, const char *, va_list);
+#include <sys/types.h>
+extern int vsnprintf(char *, size_t, const char *, va_list);
#endif
#define var
@@ -108,6 +109,9 @@ extern int vsprintf(char *, const char *, va_list);
#include "ex_tty.h"
#include <dirent.h>
#include <time.h>
+#if !defined(HAVE_STRLCPY) || !defined(HAVE_STRLCAT)
+# include "compat.h"
+#endif
#ifndef MAXNAMLEN
#ifdef FNSIZE
@@ -167,7 +171,7 @@ struct svfile {
#ifdef notdef
char mydir[] = "/usr/preserve";
#else
-char mydir[] = "/var/lib/ex";
+char mydir[] = PRESERVEDIR;
#endif
/*
@@ -238,7 +242,7 @@ main(int argc, char *argv[])
error(catgets(catd, 2, 1,
" Wrong number of arguments to exrecover"), 0);
- strcpy(file, argv[2]);
+ strlcpy(file, argv[2], sizeof file);
/*
* Search for this file.
@@ -277,7 +281,7 @@ main(int argc, char *argv[])
while (H.Flines > 0) {
ignorl(lseek(tfile, (off_t) ((blocks[b] & BLKMSK) * BUFSIZ),
SEEK_SET));
- i = H.Flines < BUFSIZ / sizeof (line) ?
+ i = H.Flines < (ssize_t)(BUFSIZ / sizeof (line)) ?
H.Flines * sizeof (line) : BUFSIZ;
if (read(tfile, (char *) dot, i) != i) {
perror(nb);
@@ -478,7 +482,7 @@ enter(struct svfile *fp, char *fname, int count)
fp->sf_time = H.Time;
fp->sf_lines = H.Flines;
cp2 = fp->sf_name, cp = savedfile;
- while (*cp2++ = *cp++);
+ while ((*cp2++ = *cp++));
for (cp2 = fp->sf_entry, cp = fname; *cp && cp-fname < 14;)
*cp2++ = *cp++;
*cp2++ = 0;
@@ -493,7 +497,7 @@ qucmp(struct svfile *p1, struct svfile *p2)
{
register int t;
- if (t = strcmp(p1->sf_name, p2->sf_name))
+ if ((t = strcmp(p1->sf_name, p2->sf_name)))
return(t);
if (p1->sf_time > p2->sf_time)
return(-1);
@@ -537,7 +541,7 @@ findtmp(char *dir)
* name for later unlinking.
*/
tfile = bestfd;
- strcpy(nb, bestnb);
+ strlcpy(nb, bestnb, sizeof nb);
ignorl(lseek(tfile, (off_t) 0, SEEK_SET));
/*
@@ -584,7 +588,9 @@ searchdir(char *dirname)
* later, and check that this is really a file
* we are looking for.
*/
- ignore(strcat(strcat(strcpy(nb, dirname), "/"), dirent->d_name));
+ strlcpy(nb, dirname, sizeof nb);
+ strlcat(nb, "/", sizeof nb);
+ strlcat(nb, dirent->d_name, sizeof nb);
if (yeah(nb)) {
/*
* Well, it is the file we are looking for.
@@ -597,7 +603,7 @@ searchdir(char *dirname)
ignore(close(bestfd));
bestfd = dup(tfile);
besttime = H.Time;
- strcpy(bestnb, nb);
+ strlcpy(bestnb, nb, sizeof bestnb);
}
/*
* Count versions so user can be told there are
@@ -754,6 +760,7 @@ putfile(int unused)
register char *fp, *lp;
register int nib;
+ (void)unused;
a1 = addr1;
clrstats();
cntln = addr2 - a1 + 1;
@@ -816,7 +823,7 @@ getline(line tl)
bp = getblock(tl, READ);
nl = nleft;
tl &= ~OFFMSK;
- while (*lp++ = *bp++)
+ while ((*lp++ = *bp++))
if (--nl == 0) {
bp = getblock(tl += INCRMT, READ);
nl = nleft;
@@ -888,7 +895,7 @@ xvfprintf(xFILE *fp, char *fmt, va_list ap)
if (fp != xstderr)
return;
- vsprintf(buf, fmt, ap);
+ vsnprintf(buf, sizeof buf, fmt, ap);
write(2, buf, strlen(buf));
}