Add compatibility define for fseeko(3).

This is better than cluttering up the code with #ifdefs for obsolete
systems.
This commit is contained in:
Todd C. Miller
2020-02-15 10:22:15 -07:00
parent e7bd19bd1e
commit 92e42ff548
4 changed files with 7 additions and 16 deletions

View File

@@ -390,6 +390,13 @@ int getdomainname(char *, size_t);
# endif
#endif /* __hpux && !__LP64__ */
/*
* Older systems may lack fseeko(3), just use fseek(3) instead.
*/
#ifndef HAVE_FSEEKO
# define fseeko(f, o, w) fseek((f), (long)(o), (w))
#endif
/*
* Compatibility defines for OpenSSL 1.0.2 (not needed for 1.1.x)
*/

View File

@@ -696,11 +696,7 @@ iolog_seek(struct iolog_file *iol, off_t offset, int whence)
ret = gzseek(iol->fd.g, offset, whence);
else
#endif
#ifdef HAVE_FSEEKO
ret = fseeko(iol->fd.f, offset, whence);
#else
ret = fseek(iol->fd.f, offset, whence);
#endif
//debug_return_off_t(ret);
return ret;

View File

@@ -60,10 +60,6 @@
#include "sudo_util.h"
#include "pathnames.h"
#ifndef HAVE_FSEEKO
# define fseeko(f, o, w) fseek((f), (o), (w))
#endif
static int audit_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static sudo_conv_t audit_conv;
static sudo_printf_t audit_printf;

View File

@@ -344,11 +344,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
}
}
utmp_fill(to_line, user, ut_old, &utbuf);
# ifdef HAVE_FSEEKO
if (fseeko(fp, slot * (off_t)sizeof(utbuf), SEEK_SET) == 0) {
# else
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) {
# endif
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
ret = true;
}
@@ -381,11 +377,7 @@ utmp_logout(const char *line, int status)
# endif
utmp_settime(&utbuf);
/* Back up and overwrite record. */
# ifdef HAVE_FSEEKO
if (fseeko(fp, (off_t)0 - (off_t)sizeof(utbuf), SEEK_CUR) == 0) {
# else
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) {
# endif
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
ret = true;
}