Do not cause Undefined Behavior in vi(1)
Replace unportable manual calculation of alignof() that causes UB, with a GCC extension __alignof__. This fixes a problem reported by UBSan with the MKSANITIZER distribution.
This commit is contained in:
parent
911756fc6b
commit
4e2759a682
6
external/bsd/nvi/dist/common/log.c
vendored
6
external/bsd/nvi/dist/common/log.c
vendored
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: log.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
|
/* $NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $ */
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993, 1994
|
* Copyright (c) 1992, 1993, 1994
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
@ -16,7 +16,7 @@
|
|||||||
static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp (Berkeley) Date: 2002/03/02 23:12:13 ";
|
static const char sccsid[] = "Id: log.c,v 10.26 2002/03/02 23:12:13 skimo Exp (Berkeley) Date: 2002/03/02 23:12:13 ";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: log.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
|
__RCSID("$NetBSD: log.c,v 1.4 2018/06/16 18:54:52 kamil Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -90,7 +90,7 @@ typedef struct {
|
|||||||
char data[sizeof(u_char) /* type */ + sizeof(db_recno_t)];
|
char data[sizeof(u_char) /* type */ + sizeof(db_recno_t)];
|
||||||
CHAR_T str[1];
|
CHAR_T str[1];
|
||||||
} log_t;
|
} log_t;
|
||||||
#define CHAR_T_OFFSET ((char *)(((log_t*)0)->str) - (char *)0)
|
#define CHAR_T_OFFSET (__alignof__(log_t))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* log_init --
|
* log_init --
|
||||||
|
Loading…
Reference in New Issue
Block a user