sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-28 21:30:53 +00:00
parent 6bd4a87a12
commit 6fc9e02a30
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
25 changed files with 193 additions and 130 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: date.c,v 1.59 2022/09/23 16:58:33 florian Exp $ */ /* $OpenBSD: date.c,v 1.60 2024/04/28 16:43:15 florian Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */ /* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/* /*
@ -151,6 +151,8 @@ setthetime(char *p, const char *pformat)
err(1, "pledge"); err(1, "pledge");
lt = localtime(&tval); lt = localtime(&tval);
if (lt == NULL)
errx(1, "conversion error");
lt->tm_isdst = -1; /* correct for DST */ lt->tm_isdst = -1; /* correct for DST */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lex.c,v 1.79 2023/02/08 17:22:10 kn Exp $ */ /* $OpenBSD: lex.c,v 1.80 2024/04/28 16:43:15 florian Exp $ */
/* /*
* lexical analysis and source input * lexical analysis and source input
@ -1251,7 +1251,11 @@ dopprompt(const char *sp, int ntruncate, const char **spp, int doprint)
case 'd': /* '\' 'd' Dow Mon DD */ case 'd': /* '\' 'd' Dow Mon DD */
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
strftime(strbuf, sizeof strbuf, "%a %b %d", tm); if (tm)
strftime(strbuf, sizeof strbuf,
"%a %b %d", tm);
else
strbuf[0] = '\0';
break; break;
case 'D': /* '\' 'D' '{' strftime format '}' */ case 'D': /* '\' 'D' '{' strftime format '}' */
p = strchr(cp + 2, '}'); p = strchr(cp + 2, '}');
@ -1266,7 +1270,11 @@ dopprompt(const char *sp, int ntruncate, const char **spp, int doprint)
*p = '\0'; *p = '\0';
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
strftime(strbuf, sizeof strbuf, tmpbuf, tm); if (tm)
strftime(strbuf, sizeof strbuf, tmpbuf,
tm);
else
strbuf[0] = '\0';
cp = strchr(cp + 2, '}'); cp = strchr(cp + 2, '}');
break; break;
case 'e': /* '\' 'e' escape */ case 'e': /* '\' 'e' escape */
@ -1315,22 +1323,38 @@ dopprompt(const char *sp, int ntruncate, const char **spp, int doprint)
case 't': /* '\' 't' 24 hour HH:MM:SS */ case 't': /* '\' 't' 24 hour HH:MM:SS */
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
strftime(strbuf, sizeof strbuf, "%T", tm); if (tm)
strftime(strbuf, sizeof strbuf, "%T",
tm);
else
strbuf[0] = '\0';
break; break;
case 'T': /* '\' 'T' 12 hour HH:MM:SS */ case 'T': /* '\' 'T' 12 hour HH:MM:SS */
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
strftime(strbuf, sizeof strbuf, "%l:%M:%S", tm); if (tm)
strftime(strbuf, sizeof strbuf,
"%l:%M:%S", tm);
else
strbuf[0] = '\0';
break; break;
case '@': /* '\' '@' 12 hour am/pm format */ case '@': /* '\' '@' 12 hour am/pm format */
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
strftime(strbuf, sizeof strbuf, "%r", tm); if (tm)
strftime(strbuf, sizeof strbuf, "%r",
tm);
else
strbuf[0] = '\0';
break; break;
case 'A': /* '\' 'A' 24 hour HH:MM */ case 'A': /* '\' 'A' 24 hour HH:MM */
time(&t); time(&t);
tm = localtime(&t); tm = localtime(&t);
strftime(strbuf, sizeof strbuf, "%R", tm); if (tm)
strftime(strbuf, sizeof strbuf, "%R",
tm);
else
strbuf[0] = '\0';
break; break;
case 'u': /* '\' 'u' username */ case 'u': /* '\' 'u' username */
strlcpy(strbuf, username, sizeof strbuf); strlcpy(strbuf, username, sizeof strbuf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sel_subs.c,v 1.28 2019/06/24 03:33:09 deraadt Exp $ */ /* $OpenBSD: sel_subs.c,v 1.29 2024/04/28 16:43:15 florian Exp $ */
/* $NetBSD: sel_subs.c,v 1.5 1995/03/21 09:07:42 cgd Exp $ */ /* $NetBSD: sel_subs.c,v 1.5 1995/03/21 09:07:42 cgd Exp $ */
/*- /*-
@ -572,7 +572,8 @@ str_sec(const char *p, time_t *tval)
return(-1); return(-1);
} }
lt = localtime(tval); if ((lt = localtime(tval)) == NULL)
return (-1);
if (dot != NULL) { /* .SS */ if (dot != NULL) { /* .SS */
if (strlen(++dot) != 2) if (strlen(++dot) != 2)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: print.c,v 1.88 2024/01/28 19:05:33 deraadt Exp $ */ /* $OpenBSD: print.c,v 1.89 2024/04/28 16:43:15 florian Exp $ */
/* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */
/*- /*-
@ -524,6 +524,10 @@ started(const struct pinfo *pi, VARENT *ve)
startt = kp->p_ustart_sec; startt = kp->p_ustart_sec;
tp = localtime(&startt); tp = localtime(&startt);
if (tp == NULL) {
(void)printf("%-*s", v->width, "-");
return;
}
if (!now) if (!now)
(void)time(&now); (void)time(&now);
if (now - kp->p_ustart_sec < 12 * SECSPERHOUR) { if (now - kp->p_ustart_sec < 12 * SECSPERHOUR) {

View File

@ -40,6 +40,7 @@
./usr/share/man/man1/ci.1 ./usr/share/man/man1/ci.1
./usr/share/man/man1/cksum.1 ./usr/share/man/man1/cksum.1
./usr/share/man/man1/clean-old-distfiles.1 ./usr/share/man/man1/clean-old-distfiles.1
./usr/share/man/man1/clear.1
./usr/share/man/man1/cmp.1 ./usr/share/man/man1/cmp.1
./usr/share/man/man1/co.1 ./usr/share/man/man1/co.1
./usr/share/man/man1/col.1 ./usr/share/man/man1/col.1
@ -487,7 +488,6 @@
./usr/share/man/man1/tmux.1 ./usr/share/man/man1/tmux.1
./usr/share/man/man1/top.1 ./usr/share/man/man1/top.1
./usr/share/man/man1/touch.1 ./usr/share/man/man1/touch.1
./usr/share/man/man1/tput.1
./usr/share/man/man1/tr.1 ./usr/share/man/man1/tr.1
./usr/share/man/man1/tradcpp.1 ./usr/share/man/man1/tradcpp.1
./usr/share/man/man1/true.1 ./usr/share/man/man1/true.1

View File

@ -1,4 +1,4 @@
/* $OpenBSD: fvwrite.c,v 1.21 2023/10/06 16:41:02 millert Exp $ */ /* $OpenBSD: fvwrite.c,v 1.22 2024/04/28 14:28:02 millert Exp $ */
/*- /*-
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -31,6 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -76,11 +77,12 @@ __sfvwrite(FILE *fp, struct __suio *uio)
} }
if (fp->_flags & __SNBF) { if (fp->_flags & __SNBF) {
/* /*
* Unbuffered: write up to BUFSIZ bytes at a time. * Unbuffered: write up to INT_MAX bytes at a time, to not
* truncate the value of len if it is greater than 2^31 bytes.
*/ */
do { do {
GETIOV(;); GETIOV(;);
w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ)); w = (*fp->_write)(fp->_cookie, p, MIN(len, INT_MAX));
if (w <= 0) if (w <= 0)
goto err; goto err;
p += w; p += w;
@ -90,7 +92,8 @@ __sfvwrite(FILE *fp, struct __suio *uio)
/* /*
* Fully buffered: fill partially full buffer, if any, * Fully buffered: fill partially full buffer, if any,
* and then flush. If there is no partial buffer, write * and then flush. If there is no partial buffer, write
* one _bf._size byte chunk directly (without copying). * entire payload directly (without copying) up to a
* multiple of the buffer size.
* *
* String output is a special case: write as many bytes * String output is a special case: write as many bytes
* as fit, but pretend we wrote everything. This makes * as fit, but pretend we wrote everything. This makes
@ -134,7 +137,15 @@ __sfvwrite(FILE *fp, struct __suio *uio)
if (__sflush(fp)) if (__sflush(fp))
goto err; goto err;
} else if (len >= (w = fp->_bf._size)) { } else if (len >= (w = fp->_bf._size)) {
/* write directly */ /*
* Write directly up to INT_MAX or greatest
* multiple of buffer size (whichever is
* smaller), keeping in the memory buffer the
* remaining part of payload that is smaller
* than buffer size.
*/
if (w != 0)
w = MIN(w * (len / w), INT_MAX);
w = (*fp->_write)(fp->_cookie, p, w); w = (*fp->_write)(fp->_cookie, p, w);
if (w <= 0) if (w <= 0)
goto err; goto err;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ftpcmd.y,v 1.74 2023/03/08 04:43:05 guenther Exp $ */ /* $OpenBSD: ftpcmd.y,v 1.75 2024/04/28 16:42:53 florian Exp $ */
/* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */ /* $NetBSD: ftpcmd.y,v 1.7 1996/04/08 19:03:11 jtc Exp $ */
/* /*
@ -613,6 +613,11 @@ cmd
} else { } else {
struct tm *t; struct tm *t;
t = gmtime(&stbuf.st_mtime); t = gmtime(&stbuf.st_mtime);
if (t == NULL) {
/* invalid time, use epoch */
stbuf.st_mtime = 0;
t = gmtime(&stbuf.st_mtime);
}
reply(213, reply(213,
"%04d%02d%02d%02d%02d%02d", "%04d%02d%02d%02d%02d%02d",
1900 + t->tm_year, 1900 + t->tm_year,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.54 2019/06/28 13:32:53 deraadt Exp $ */ /* $OpenBSD: main.c,v 1.55 2024/04/28 16:42:53 florian Exp $ */
/*- /*-
* Copyright (c) 1980, 1993 * Copyright (c) 1980, 1993
@ -562,9 +562,11 @@ putf(char *cp)
break; break;
case 'd': { case 'd': {
(void)time(&t); struct tm *tm;
(void)strftime(db, sizeof(db), time(&t);
"%l:%M%p on %A, %d %B %Y", localtime(&t)); if ((tm = localtime(&t)) != NULL)
if (strftime(db, sizeof(db),
"%l:%M%p on %A, %d %B %Y", tm) != 0)
xputs(db); xputs(db);
break; break;
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mib.c,v 1.7 2023/11/21 08:49:08 martijn Exp $ */ /* $OpenBSD: mib.c,v 1.8 2024/04/28 16:42:53 florian Exp $ */
/* /*
* Copyright (c) 2022 Martijn van Duren <martijn@openbsd.org> * Copyright (c) 2022 Martijn van Duren <martijn@openbsd.org>
@ -296,9 +296,11 @@ mib_hrsystemdate(struct agentx_varbind *vb)
int tzoffset; int tzoffset;
unsigned short year; unsigned short year;
memset(s, 0, sizeof(s));
(void)time(&now); (void)time(&now);
ptm = localtime(&now); ptm = localtime(&now);
if (ptm != NULL) {
year = htons(ptm->tm_year + 1900); year = htons(ptm->tm_year + 1900);
memcpy(s, &year, 2); memcpy(s, &year, 2);
s[2] = ptm->tm_mon + 1; s[2] = ptm->tm_mon + 1;
@ -316,7 +318,7 @@ mib_hrsystemdate(struct agentx_varbind *vb)
s[9] = abs(tzoffset) / 3600; s[9] = abs(tzoffset) / 3600;
s[10] = (abs(tzoffset) - (s[9] * 3600)) / 60; s[10] = (abs(tzoffset) - (s[9] * 3600)) / 60;
}
agentx_varbind_nstring(vb, s, sizeof(s)); agentx_varbind_nstring(vb, s, sizeof(s));
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: announce.c,v 1.25 2019/06/28 13:32:53 deraadt Exp $ */ /* $OpenBSD: announce.c,v 1.26 2024/04/28 16:42:53 florian Exp $ */
/* /*
* Copyright (c) 1983 Regents of the University of California. * Copyright (c) 1983 Regents of the University of California.
@ -102,9 +102,14 @@ print_mesg(FILE *tf, CTL_MSG *request, char *remote_machine)
sizes[i] = strlen(line_buf[i]); sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]); max_size = max(max_size, sizes[i]);
i++; i++;
if (localclock) {
(void)snprintf(line_buf[i], N_CHARS, (void)snprintf(line_buf[i], N_CHARS,
"Message from Talk_Daemon@%s at %d:%02d ...", "Message from Talk_Daemon@%s at %d:%02d ...",
hostname, localclock->tm_hour , localclock->tm_min ); hostname, localclock->tm_hour , localclock->tm_min );
} else {
(void)snprintf(line_buf[i], N_CHARS,
"Message from Talk_Daemon@%s ...", hostname);
}
sizes[i] = strlen(line_buf[i]); sizes[i] = strlen(line_buf[i]);
max_size = max(max_size, sizes[i]); max_size = max(max_size, sizes[i]);
i++; i++;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dhclient.c,v 1.727 2022/07/02 17:21:32 deraadt Exp $ */ /* $OpenBSD: dhclient.c,v 1.728 2024/04/28 16:43:42 florian Exp $ */
/* /*
* Copyright 2004 Henning Brauer <henning@openbsd.org> * Copyright 2004 Henning Brauer <henning@openbsd.org>
@ -2079,6 +2079,7 @@ lease_as_string(char *type, struct client_lease *lease)
static char string[8192]; static char string[8192];
char timebuf[27]; /* 6 2017/04/08 05:47:50 UTC; */ char timebuf[27]; /* 6 2017/04/08 05:47:50 UTC; */
struct option_data *opt; struct option_data *opt;
struct tm *tm;
char *buf, *name; char *buf, *name;
time_t t; time_t t;
size_t rslt; size_t rslt;
@ -2138,19 +2139,25 @@ lease_as_string(char *type, struct client_lease *lease)
free(buf); free(buf);
t = lease->epoch + lease_renewal(lease); t = lease->epoch + lease_renewal(lease);
rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, gmtime(&t)); if ((tm = gmtime(&t)) == NULL)
return NULL;
rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, tm);
if (rslt == 0) if (rslt == 0)
return NULL; return NULL;
append_statement(string, sizeof(string), " renew ", timebuf); append_statement(string, sizeof(string), " renew ", timebuf);
t = lease->epoch + lease_rebind(lease); t = lease->epoch + lease_rebind(lease);
rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, gmtime(&t)); if ((tm = gmtime(&t)) == NULL)
return NULL;
rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, tm);
if (rslt == 0) if (rslt == 0)
return NULL; return NULL;
append_statement(string, sizeof(string), " rebind ", timebuf); append_statement(string, sizeof(string), " rebind ", timebuf);
t = lease->epoch + lease_expiry(lease); t = lease->epoch + lease_expiry(lease);
rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, gmtime(&t)); if ((tm = gmtime(&t)) == NULL)
return NULL;
rslt = strftime(timebuf, sizeof(timebuf), DB_TIMEFMT, tm);
if (rslt == 0) if (rslt == 0)
return NULL; return NULL;
append_statement(string, sizeof(string), " expire ", timebuf); append_statement(string, sizeof(string), " expire ", timebuf);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.64 2018/01/15 09:54:48 mpi Exp $ */ /* $OpenBSD: log.c,v 1.65 2024/04/28 16:43:42 florian Exp $ */
/* $EOM: log.c,v 1.30 2000/09/29 08:19:23 niklas Exp $ */ /* $EOM: log.c,v 1.30 2000/09/29 08:19:23 niklas Exp $ */
/* /*
@ -182,7 +182,11 @@ _log_print(int error, int syslog_level, const char *fmt, va_list ap,
if (log_output) { if (log_output) {
gettimeofday(&now, 0); gettimeofday(&now, 0);
t = now.tv_sec; t = now.tv_sec;
if ((tm = localtime(&t)) == NULL) {
/* Invalid time, use the epoch. */
t = 0;
tm = localtime(&t); tm = localtime(&t);
}
if (class >= 0) if (class >= 0)
snprintf(nbuf, sizeof nbuf, snprintf(nbuf, sizeof nbuf,
"%02d%02d%02d.%06ld %s %02d ", "%02d%02d%02d.%06ld %s %02d ",

View File

@ -1,4 +1,4 @@
/* $OpenBSD: policy.c,v 1.102 2021/10/22 12:30:54 bluhm Exp $ */ /* $OpenBSD: policy.c,v 1.103 2024/04/28 16:43:42 florian Exp $ */
/* $EOM: policy.c,v 1.49 2000/10/24 13:33:39 niklas Exp $ */ /* $EOM: policy.c,v 1.49 2000/10/24 13:33:39 niklas Exp $ */
/* /*
@ -1728,13 +1728,23 @@ policy_callback(char *name)
return phase_1; return phase_1;
if (strcmp(name, "GMTTimeOfDay") == 0) { if (strcmp(name, "GMTTimeOfDay") == 0) {
struct tm *tm;
tt = time(NULL); tt = time(NULL);
strftime(mytimeofday, 14, "%Y%m%d%H%M%S", gmtime(&tt)); if ((tm = gmtime(&tt)) == NULL) {
log_error("policy_callback: invalid time %lld", tt);
goto bad;
}
strftime(mytimeofday, 14, "%Y%m%d%H%M%S", tm);
return mytimeofday; return mytimeofday;
} }
if (strcmp(name, "LocalTimeOfDay") == 0) { if (strcmp(name, "LocalTimeOfDay") == 0) {
struct tm *tm;
tt = time(NULL); tt = time(NULL);
strftime(mytimeofday, 14, "%Y%m%d%H%M%S", localtime(&tt)); if ((tm = localtime(&tt)) == NULL) {
log_error("policy_callback: invalid time %lld", tt);
goto bad;
}
strftime(mytimeofday, 14, "%Y%m%d%H%M%S", tm);
return mytimeofday; return mytimeofday;
} }
if (strcmp(name, "initiator") == 0) if (strcmp(name, "initiator") == 0)

View File

@ -1,4 +1,4 @@
/* $OpenBSD: x509.c,v 1.125 2022/01/16 14:30:11 naddy Exp $ */ /* $OpenBSD: x509.c,v 1.126 2024/04/28 16:43:42 florian Exp $ */
/* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */ /* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */
/* /*
@ -222,8 +222,15 @@ x509_generate_kn(int id, X509 *cert)
if (((tm = X509_get_notBefore(cert)) == NULL) || if (((tm = X509_get_notBefore(cert)) == NULL) ||
(tm->type != V_ASN1_UTCTIME && (tm->type != V_ASN1_UTCTIME &&
tm->type != V_ASN1_GENERALIZEDTIME)) { tm->type != V_ASN1_GENERALIZEDTIME)) {
tt = time(0); struct tm *ltm;
strftime(before, 14, "%Y%m%d%H%M%S", localtime(&tt));
tt = time(NULL);
if ((ltm = localtime(&tt)) == NULL) {
LOG_DBG((LOG_POLICY, 30,
"x509_generate_kn: invalid local time"));
goto fail;
}
strftime(before, 14, "%Y%m%d%H%M%S", ltm);
timecomp = "LocalTimeOfDay"; timecomp = "LocalTimeOfDay";
} else { } else {
if (tm->data[tm->length - 1] == 'Z') { if (tm->data[tm->length - 1] == 'Z') {
@ -312,8 +319,15 @@ x509_generate_kn(int id, X509 *cert)
if (tm == NULL || if (tm == NULL ||
(tm->type != V_ASN1_UTCTIME && (tm->type != V_ASN1_UTCTIME &&
tm->type != V_ASN1_GENERALIZEDTIME)) { tm->type != V_ASN1_GENERALIZEDTIME)) {
struct tm *ltm;
tt = time(0); tt = time(0);
strftime(after, 14, "%Y%m%d%H%M%S", localtime(&tt)); if ((ltm = localtime(&tt)) == NULL) {
LOG_DBG((LOG_POLICY, 30,
"x509_generate_kn: invalid local time"));
goto fail;
}
strftime(after, 14, "%Y%m%d%H%M%S", ltm);
timecomp2 = "LocalTimeOfDay"; timecomp2 = "LocalTimeOfDay";
} else { } else {
if (tm->data[tm->length - 1] == 'Z') { if (tm->data[tm->length - 1] == 'Z') {

View File

@ -1,4 +1,4 @@
/* $OpenBSD: newfs_msdos.c,v 1.28 2021/07/11 15:39:58 kettenis Exp $ */ /* $OpenBSD: newfs_msdos.c,v 1.29 2024/04/28 16:43:42 florian Exp $ */
/* /*
* Copyright (c) 1998 Robert Nordier * Copyright (c) 1998 Robert Nordier
@ -550,7 +550,9 @@ main(int argc, char *argv[])
if (!opt_N) { if (!opt_N) {
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
now = tv.tv_sec; now = tv.tv_sec;
tm = localtime(&now); if ((tm = localtime(&now)) == NULL)
errx(1, "Invalid time");
if (!(img = malloc(bpb.bps))) if (!(img = malloc(bpb.bps)))
err(1, NULL); err(1, NULL);
dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft; dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: route.c,v 1.265 2023/03/17 16:11:09 claudio Exp $ */ /* $OpenBSD: route.c,v 1.266 2024/04/28 16:43:42 florian Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/* /*
@ -1878,7 +1878,10 @@ bfd_calc_uptime(time_t time)
fmt = "%Ss"; fmt = "%Ss";
tp = localtime(&time); tp = localtime(&time);
if (tp)
(void)strftime(buf, sizeof(buf), fmt, tp); (void)strftime(buf, sizeof(buf), fmt, tp);
else
buf[0] = '\0';
return (buf); return (buf);
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: shutdown.c,v 1.55 2023/04/19 12:58:15 jsg Exp $ */ /* $OpenBSD: shutdown.c,v 1.56 2024/04/28 16:43:42 florian Exp $ */
/* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */ /* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */
/* /*
@ -345,8 +345,13 @@ timewarn(time_t timeleft)
if (timeleft > 10 * 60) { if (timeleft > 10 * 60) {
shuttime = time(NULL) + timeleft; shuttime = time(NULL) + timeleft;
lt = localtime(&shuttime); lt = localtime(&shuttime);
if (lt != NULL) {
strftime(when, sizeof(when), "%H:%M %Z", lt); strftime(when, sizeof(when), "%H:%M %Z", lt);
dprintf(fd[1], "System going down at %s\n\n", when); dprintf(fd[1], "System going down at %s\n\n", when);
} else
dprintf(fd[1], "System going down in %lld minute%s\n\n",
(long long)(timeleft / 60),
(timeleft > 60) ? "s" : "");
} else if (timeleft > 59) { } else if (timeleft > 59) {
dprintf(fd[1], "System going down in %lld minute%s\n\n", dprintf(fd[1], "System going down in %lld minute%s\n\n",
(long long)(timeleft / 60), (timeleft > 60) ? "s" : ""); (long long)(timeleft / 60), (timeleft > 60) ? "s" : "");
@ -525,6 +530,9 @@ getoffset(char *timearg)
time(&now); time(&now);
lt = localtime(&now); /* current time val */ lt = localtime(&now); /* current time val */
if (lt == NULL)
badtime();
switch (strlen(timearg)) { switch (strlen(timearg)) {
case 10: case 10:
this_year = lt->tm_year; this_year = lt->tm_year;
@ -595,10 +603,17 @@ nolog(time_t timeleft)
(void)signal(SIGTERM, finish); (void)signal(SIGTERM, finish);
shuttime = time(NULL) + timeleft; shuttime = time(NULL) + timeleft;
tm = localtime(&shuttime); tm = localtime(&shuttime);
if (tm && (logfd = open(_PATH_NOLOGIN, O_WRONLY|O_CREAT|O_TRUNC, if ((logfd = open(_PATH_NOLOGIN, O_WRONLY|O_CREAT|O_TRUNC,
0664)) >= 0) { 0664)) >= 0) {
if (tm) {
strftime(when, sizeof(when), "at %H:%M %Z", tm); strftime(when, sizeof(when), "at %H:%M %Z", tm);
dprintf(logfd, "\n\nNO LOGINS: System going down %s\n\n", when); dprintf(logfd,
"\n\nNO LOGINS: System going down %s\n\n", when);
} else
dprintf(logfd,
"\n\nNO LOGINS: System going in %lld minute%s\n\n",
(long long)(timeleft / 60),
(timeleft > 60) ? "s" : "");
close(logfd); close(logfd);
} }
} }

View File

@ -271,8 +271,8 @@ log_vmsg(int pri, const char* type,
} }
now = (time_t)time(NULL); now = (time_t)time(NULL);
#if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) #if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R)
if(log_time_asc && strftime(tmbuf, sizeof(tmbuf), "%b %d %H:%M:%S", if(log_time_asc && localtime_r(&now, &tm) && strftime(tmbuf,
localtime_r(&now, &tm))%(sizeof(tmbuf)) != 0) { sizeof(tmbuf), "%b %d %H:%M:%S", &tm)%(sizeof(tmbuf)) != 0) {
/* %sizeof buf!=0 because old strftime returned max on error */ /* %sizeof buf!=0 because old strftime returned max on error */
fprintf(logfile, "%s %s[%d:%x] %s: %s\n", tmbuf, fprintf(logfile, "%s %s[%d:%x] %s: %s\n", tmbuf,
ident, (int)getpid(), tid?*tid:0, type, message); ident, (int)getpid(), tid?*tid:0, type, message);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.c,v 1.292 2024/04/03 02:01:21 guenther Exp $ */ /* $OpenBSD: machdep.c,v 1.293 2024/04/29 00:29:48 jsg Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*- /*-
@ -178,10 +178,7 @@ int biosbasemem = 0; /* base memory reported by BIOS */
u_int bootapiver = 0; /* /boot API version */ u_int bootapiver = 0; /* /boot API version */
int physmem; int physmem;
u_int64_t dumpmem_low;
u_int64_t dumpmem_high;
extern int boothowto; extern int boothowto;
int cpu_class;
paddr_t dumpmem_paddr; paddr_t dumpmem_paddr;
vaddr_t dumpmem_vaddr; vaddr_t dumpmem_vaddr;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: machdep.c,v 1.669 2023/08/23 01:55:46 cheloha Exp $ */ /* $OpenBSD: machdep.c,v 1.670 2024/04/29 00:29:48 jsg Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*- /*-
@ -191,9 +191,6 @@ int dumpsize = 0; /* pages */
long dumplo = 0; /* blocks */ long dumplo = 0; /* blocks */
int cpu_class; int cpu_class;
int i386_fpu_present;
int i386_fpu_exception;
int i386_fpu_fdivbug;
int i386_use_fxsave; int i386_use_fxsave;
int i386_has_sse; int i386_has_sse;
@ -207,7 +204,6 @@ struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL; struct vm_map *phys_map = NULL;
#if !defined(SMALL_KERNEL) #if !defined(SMALL_KERNEL)
int p4_model;
int p3_early; int p3_early;
void (*update_cpuspeed)(void) = NULL; void (*update_cpuspeed)(void) = NULL;
void via_update_sensor(void *args); void via_update_sensor(void *args);
@ -1547,7 +1543,6 @@ intel686_p4_cpu_setup(struct cpu_info *ci)
intel686_common_cpu_setup(ci); intel686_common_cpu_setup(ci);
#if !defined(SMALL_KERNEL) #if !defined(SMALL_KERNEL)
p4_model = (ci->ci_signature >> 4) & 15;
update_cpuspeed = p4_update_cpuspeed; update_cpuspeed = p4_update_cpuspeed;
#endif #endif
} }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: npx.c,v 1.74 2023/01/30 10:49:05 jsg Exp $ */ /* $OpenBSD: npx.c,v 1.75 2024/04/29 00:29:48 jsg Exp $ */
/* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */ /* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */
#if 0 #if 0
@ -132,10 +132,6 @@ static volatile u_int npx_intrs_while_probing
static volatile u_int npx_traps_while_probing static volatile u_int npx_traps_while_probing
__attribute__((section(".kudata"))); __attribute__((section(".kudata")));
extern int i386_fpu_present;
extern int i386_fpu_exception;
extern int i386_fpu_fdivbug;
#define fxsave(addr) __asm("fxsave %0" : "=m" (*addr)) #define fxsave(addr) __asm("fxsave %0" : "=m" (*addr))
#define fxrstor(addr) __asm("fxrstor %0" : : "m" (*addr)) #define fxrstor(addr) __asm("fxrstor %0" : : "m" (*addr))
#define ldmxcsr(addr) __asm("ldmxcsr %0" : : "m" (*addr)) #define ldmxcsr(addr) __asm("ldmxcsr %0" : : "m" (*addr))
@ -235,7 +231,6 @@ npxprobe1(struct isa_attach_args *ia)
*/ */
npx_type = NPX_EXCEPTION; npx_type = NPX_EXCEPTION;
ia->ia_irq = IRQUNK; /* zap the interrupt */ ia->ia_irq = IRQUNK; /* zap the interrupt */
i386_fpu_exception = 1;
} else if (npx_intrs_while_probing != 0) { } else if (npx_intrs_while_probing != 0) {
/* /*
* Bad, we are stuck with IRQ13. * Bad, we are stuck with IRQ13.
@ -278,7 +273,6 @@ npxprobe(struct device *parent, void *match, void *aux)
if (cpu_feature & CPUID_FPU) { if (cpu_feature & CPUID_FPU) {
npx_type = NPX_CPUID; npx_type = NPX_CPUID;
i386_fpu_exception = 1;
ia->ia_irq = IRQUNK; /* Don't want the interrupt vector */ ia->ia_irq = IRQUNK; /* Don't want the interrupt vector */
ia->ia_iosize = 16; ia->ia_iosize = 16;
ia->ia_msize = 0; ia->ia_msize = 0;
@ -348,7 +342,6 @@ npxinit(struct cpu_info *ci)
lcr0(rcr0() & ~(CR0_EM|CR0_TS)); lcr0(rcr0() & ~(CR0_EM|CR0_TS));
fninit(); fninit();
if (npx586bug1(4195835, 3145727) != 0) { if (npx586bug1(4195835, 3145727) != 0) {
i386_fpu_fdivbug = 1;
printf("%s: WARNING: Pentium FDIV bug detected!\n", printf("%s: WARNING: Pentium FDIV bug detected!\n",
ci->ci_dev->dv_xname); ci->ci_dev->dv_xname);
} }
@ -397,7 +390,6 @@ npxattach(struct device *parent, struct device *self, void *aux)
} }
npxinit(&cpu_info_primary); npxinit(&cpu_info_primary);
i386_fpu_present = 1;
if (i386_use_fxsave) if (i386_use_fxsave)
npxdna_func = npxdna_xmm; npxdna_func = npxdna_xmm;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pcibios.c,v 1.49 2022/02/21 10:24:28 mpi Exp $ */ /* $OpenBSD: pcibios.c,v 1.50 2024/04/29 00:29:48 jsg Exp $ */
/* $NetBSD: pcibios.c,v 1.5 2000/08/01 05:23:59 uch Exp $ */ /* $NetBSD: pcibios.c,v 1.5 2000/08/01 05:23:59 uch Exp $ */
/* /*
@ -101,7 +101,6 @@
#include <machine/biosvar.h> #include <machine/biosvar.h>
int pcibios_flags; int pcibios_flags;
int pcibios_present;
struct pcibios_pir_header pcibios_pir_header; struct pcibios_pir_header pcibios_pir_header;
struct pcibios_intr_routing *pcibios_pir_table; struct pcibios_intr_routing *pcibios_pir_table;
@ -187,8 +186,6 @@ pcibiosattach(struct device *parent, struct device *self, void *aux)
*/ */
pci_mode = mech1 ? 1 : 2; pci_mode = mech1 ? 1 : 2;
pcibios_present = 1;
/* /*
* Find the PCI IRQ Routing table. * Find the PCI IRQ Routing table.
*/ */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ac97.c,v 1.84 2018/04/11 04:48:31 ratchov Exp $ */ /* $OpenBSD: ac97.c,v 1.85 2024/04/29 00:29:48 jsg Exp $ */
/* /*
* Copyright (c) 1999, 2000 Constantine Sapuntzakis * Copyright (c) 1999, 2000 Constantine Sapuntzakis
@ -69,17 +69,6 @@
#include <dev/audio_if.h> #include <dev/audio_if.h>
#include <dev/ic/ac97.h> #include <dev/ic/ac97.h>
/* default parameters; supported by all ac97 codecs */
const struct audio_params ac97_audio_default = {
48000, /* sample_rate */
AUDIO_ENCODING_SLINEAR_LE, /* encoding */
16, /* precision */
2, /* bps */
1, /* msb */
2 /* channels */
};
const struct audio_mixer_enum ac97_on_off = { const struct audio_mixer_enum ac97_on_off = {
2, 2,
{ { { AudioNoff } , 0 }, { { { AudioNoff } , 0 },

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mpls_raw.c,v 1.19 2022/02/22 01:15:02 guenther Exp $ */ /* $OpenBSD: mpls_raw.c,v 1.20 2024/04/29 00:29:48 jsg Exp $ */
/* /*
* Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project.
@ -45,8 +45,6 @@
#include <netmpls/mpls.h> #include <netmpls/mpls.h>
int mpls_defttl = 255; int mpls_defttl = 255;
int mpls_push_expnull_ip = 0;
int mpls_push_expnull_ip6 = 0;
int mpls_mapttl_ip = 1; int mpls_mapttl_ip = 1;
int mpls_mapttl_ip6 = 0; int mpls_mapttl_ip6 = 0;

View File

@ -1,4 +1,4 @@
/* $Id: netproc.c,v 1.33 2022/12/14 18:32:26 florian Exp $ */ /* $Id: netproc.c,v 1.35 2024/04/28 10:09:25 tb Exp $ */
/* /*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
* *
@ -54,34 +54,19 @@ struct conn {
/* /*
* If something goes wrong (or we're tracing output), we dump the * If something goes wrong (or we're tracing output), we dump the
* current transfer's data as a debug message. * current transfer's data as a debug message.
* Make sure that print all non-printable characters as question marks
* so that we don't spam the console.
* Also, consolidate white-space.
* This of course will ruin string literals, but the intent here is just
* to show the message, not to replicate it.
*/ */
static void static void
buf_dump(const struct buf *buf) buf_dump(const struct buf *buf)
{ {
size_t i;
int j;
char *nbuf; char *nbuf;
if (buf->sz == 0) if (buf->sz == 0)
return; return;
if ((nbuf = malloc(buf->sz)) == NULL) /* must be at least 4 * srclen + 1 long */
err(EXIT_FAILURE, "malloc"); if ((nbuf = calloc(buf->sz + 1, 4)) == NULL)
err(EXIT_FAILURE, "calloc");
for (j = 0, i = 0; i < buf->sz; i++) strvisx(nbuf, buf->buf, buf->sz, VIS_SAFE);
if (isspace((unsigned char)buf->buf[i])) { dodbg("transfer buffer: [%s] (%zu bytes)", nbuf, buf->sz);
nbuf[j++] = ' ';
while (isspace((unsigned char)buf->buf[i]))
i++;
i--;
} else
nbuf[j++] = isprint((unsigned char)buf->buf[i]) ?
buf->buf[i] : '?';
dodbg("transfer buffer: [%.*s] (%zu bytes)", j, nbuf, buf->sz);
free(nbuf); free(nbuf);
} }
@ -678,7 +663,7 @@ netproc(int kfd, int afd, int Cfd, int cfd, int dfd, int rfd,
{ {
int rc = 0; int rc = 0;
size_t i; size_t i;
char *cert = NULL, *thumb = NULL, *url = NULL, *error = NULL; char *cert = NULL, *thumb = NULL, *error = NULL;
struct conn c; struct conn c;
struct capaths paths; struct capaths paths;
struct order order; struct order order;
@ -913,7 +898,6 @@ out:
close(dfd); close(dfd);
close(rfd); close(rfd);
free(cert); free(cert);
free(url);
free(thumb); free(thumb);
free(c.kid); free(c.kid);
free(c.buf.buf); free(c.buf.buf);