NetBSD Problem Report #55284
From www@netbsd.org Fri May 22 13:59:47 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 56F7E1A9227
for <gnats-bugs@gnats.NetBSD.org>; Fri, 22 May 2020 13:59:47 +0000 (UTC)
Message-Id: <20200522135946.76F7B1A9228@mollari.NetBSD.org>
Date: Fri, 22 May 2020 13:59:46 +0000 (UTC)
From: romain@dolbeau..org
Reply-To: romain@dolbeau.org
To: gnats-bugs@NetBSD.org
Subject: 'wmweather' broken on architecture where sizeof(long) < sizeof(time_t)
X-Send-Pr-Version: www-1.0
>Number: 55284
>Category: pkg
>Synopsis: 'wmweather' broken on architecture where sizeof(long) < sizeof(time_t)
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: pkg-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 22 14:00:00 +0000 2020
>Closed-Date: Fri Mar 01 19:20:21 +0000 2024
>Last-Modified: Fri Mar 01 19:20:21 +0000 2024
>Originator: Romain Dolbeau
>Release: pkgsrc 2020Q1
>Organization:
-
>Environment:
NetBSD ss20.dolbeau.name 9.0 NetBSD 9.0 (GENERIC.MP) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/sparc/compile/GENERIC.MP sparc
>Description:
'wmweather' is broken on architecture where sizeof(long) < sizeof(time_t), as it passes a pointer to a 'long' (4 bytes on NetBSD/sparc) to time(), which takes a pointer to a time_t (8 bytes).
On NetBSD/sparc said long is not 8-bytes aligned, leading to a 'Bus error' due to a misaligned load (rather than a stack corruption).
>How-To-Repeat:
start wmweather on NetBSD/sparc -> Bus error.
>Fix:
I have a patch that I will submit in a follow-up e-mail, which introduce an extra time_t variable to avoid the issue.
>Release-Note:
>Audit-Trail:
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/55284: 'wmweather' broken on architecture where sizeof(long)
< sizeof(time_t)
Date: Wed, 9 Jun 2021 04:39:46 +0000
Here's the follow-up email, which got sent to gnats-admin (send PR
comments to gnats-bugs; stuff sent to the administrator address gets
mixed with a flood of other things and tends to get lost or severely
delayed)
------
From: Romain Dolbeau <romain@dolbeau.org>
To: gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/55284: 'wmweather' broken on architecture where sizeof(long) <
sizeof(time_t)
Date: Fri, 22 May 2020 16:05:24 +0200
This is a patch including the needed fix, adding a properly typed variable 'tl'.
It includes the already-existing patch in pkgsrc.
Cordially,
--
Romain Dolbeau
$NetBSD: patch-wmweather.c,v 1.1 2016/06/23 18:24:07 dholland Exp $
Use ctype.h functions correctly.
--- wmweather.c.orig 2016-08-07 19:02:35.000000000 +0200
+++ wmweather.c 2020-05-22 15:22:37.658297228 +0200
@@ -269,7 +269,7 @@
exit(1);
}
for (i = 0; i < 4; i++)
- optarg[i] = toupper(optarg[i]);
+ optarg[i] = toupper((unsigned char)optarg[i]);
if (station != NULL)
free(station);
station = strdup(optarg);
@@ -406,7 +406,7 @@
exit(1);
}
for (i = 0; i < 4; i++)
- optarg[i] = toupper(optarg[i]);
+ optarg[i] = toupper((unsigned char)optarg[i]);
if (station != NULL)
free(station);
station = optarg;
@@ -690,11 +690,12 @@
char buffer[MAX_STRING], *i;
int line, n, q, sgn;
long l = 0;
+ time_t tl = 0;
- time(&l);
- tm = gmtime(&l);
+ time(&tl);
+ tm = gmtime(&tl);
utc_diff = tm->tm_hour;
- tm = localtime(&l);
+ tm = localtime(&tl);
utc_diff = (tm->tm_hour - utc_diff + 24) % 24 * 3600;
if (stat(report, &rst) < 0 && errno != ENOENT) {
@@ -1129,8 +1130,8 @@
} else {
- time(&l);
- tm = localtime(&l);
+ time(&tl);
+ tm = localtime(&tl);
if (gusting) {
showwinddir = tm->tm_sec % 30 < 10;
showgusting = tm->tm_sec % 30 >= 10 && tm->tm_sec % 30 < 20;
From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/55284 CVS commit: pkgsrc/x11/wmweather
Date: Sat, 10 Jul 2021 17:13:44 +0000
Module Name: pkgsrc
Committed By: dholland
Date: Sat Jul 10 17:13:44 UTC 2021
Modified Files:
pkgsrc/x11/wmweather: Makefile distinfo
pkgsrc/x11/wmweather/patches: patch-wmweather.c
Log Message:
x11/wmweather: apply patch from Romain Dolbeau in PR 55284.
Fixes time_t abuse leading to crashes on 32-bit platforms.
To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 pkgsrc/x11/wmweather/Makefile
cvs rdiff -u -r1.13 -r1.14 pkgsrc/x11/wmweather/distinfo
cvs rdiff -u -r1.1 -r1.2 pkgsrc/x11/wmweather/patches/patch-wmweather.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 10 Jul 2021 17:15:38 +0000
State-Changed-Why:
Committed, if you get a chance please check that it works and I didn't
mess up
State-Changed-From-To: feedback->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Fri, 01 Mar 2024 19:20:21 +0000
State-Changed-Why:
Feedback timeout, assuming fixed
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.