Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern ntp(9): Avoid left shift of negative.
details: https://anonhg.NetBSD.org/src/rev/49994d8144b4
branches: trunk
changeset: 363477:49994d8144b4
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Mar 13 12:57:33 2022 +0000
description:
ntp(9): Avoid left shift of negative.
Kinda silly that this is UB at all...
Reported-by: syzbot+baf29c7f0756293b8257%syzkaller.appspotmail.com@localhost
diffstat:
sys/kern/kern_ntptime.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diffs (30 lines):
diff -r e613360206ae -r 49994d8144b4 sys/kern/kern_ntptime.c
--- a/sys/kern/kern_ntptime.c Sun Mar 13 12:49:36 2022 +0000
+++ b/sys/kern/kern_ntptime.c Sun Mar 13 12:57:33 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ntptime.c,v 1.62 2022/03/13 12:30:47 riastradh Exp $ */
+/* $NetBSD: kern_ntptime.c,v 1.63 2022/03/13 12:57:33 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/sys/kern/kern_ntptime.c,v 1.59 2005/05/28 14:34:41 rwatson Exp $"); */
-__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.62 2022/03/13 12:30:47 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ntptime.c,v 1.63 2022/03/13 12:57:33 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ntp.h"
@@ -383,7 +383,10 @@
ntv->offset = L_GINT(time_offset);
else
ntv->offset = L_GINT(time_offset) / 1000; /* XXX rounding ? */
- ntv->freq = L_GINT((time_freq / 1000LL) << 16);
+ if (time_freq < 0)
+ ntv->freq = L_GINT(-((-time_freq / 1000LL) << 16));
+ else
+ ntv->freq = L_GINT((time_freq / 1000LL) << 16);
ntv->maxerror = time_maxerror;
ntv->esterror = time_esterror;
ntv->status = time_status;
Home |
Main Index |
Thread Index |
Old Index