* commit 'c01893cde28ce9c8c760a29b7829159ca9de30be': Sync with current OpenBSD stdio.
This commit is contained in:
commit
c4ced713b8
@ -673,6 +673,7 @@ LOCAL_CFLAGS := \
|
||||
$(libc_common_cflags) \
|
||||
-I$(LOCAL_PATH)/upstream-openbsd/android/include \
|
||||
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \
|
||||
-I$(LOCAL_PATH)/upstream-openbsd/lib/libc/gdtoa/ \
|
||||
-include openbsd-compat.h
|
||||
LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
|
||||
LOCAL_CPPFLAGS := $(libc_common_cppflags)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: fgetln.c,v 1.11 2009/11/21 09:53:44 guenther Exp $ */
|
||||
/* $OpenBSD: fgetln.c,v 1.12 2013/11/12 07:04:06 deraadt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -43,7 +43,7 @@
|
||||
* so we add 1 here.
|
||||
#endif
|
||||
*/
|
||||
int
|
||||
static int
|
||||
__slbexpand(FILE *fp, size_t newsize)
|
||||
{
|
||||
void *p;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: fputws.c,v 1.6 2013/04/17 17:40:35 tedu Exp $ */
|
||||
/* $OpenBSD: fputws.c,v 1.7 2013/11/12 07:04:35 deraadt Exp $ */
|
||||
/* $NetBSD: fputws.c,v 1.1 2003/03/07 07:11:37 tshiozak Exp $ */
|
||||
|
||||
/*-
|
||||
@ -34,8 +34,7 @@
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
#include "local.h"
|
||||
|
||||
wint_t __fputwc_unlock(wchar_t wc, FILE *fp);
|
||||
#include "fvwrite.h"
|
||||
|
||||
int
|
||||
fputws(ws, fp)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: fread.c,v 1.11 2009/11/21 09:53:44 guenther Exp $ */
|
||||
/* $OpenBSD: fread.c,v 1.12 2014/05/01 16:40:36 deraadt Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -33,8 +33,12 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include "local.h"
|
||||
|
||||
#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 4))
|
||||
|
||||
size_t
|
||||
fread(void *buf, size_t size, size_t count, FILE *fp)
|
||||
{
|
||||
@ -43,6 +47,16 @@ fread(void *buf, size_t size, size_t count, FILE *fp)
|
||||
int r;
|
||||
size_t total;
|
||||
|
||||
/*
|
||||
* Extension: Catch integer overflow
|
||||
*/
|
||||
if ((size >= MUL_NO_OVERFLOW || count >= MUL_NO_OVERFLOW) &&
|
||||
size > 0 && SIZE_MAX / size < count) {
|
||||
errno = EOVERFLOW;
|
||||
fp->_flags |= __SERR;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* ANSI and SUSv2 require a return value of 0 if size or count are 0.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vfprintf.c,v 1.63 2013/03/02 19:40:08 guenther Exp $ */
|
||||
/* $OpenBSD: vfprintf.c,v 1.65 2014/03/19 05:17:01 guenther Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
@ -216,11 +216,10 @@ __wcsconv(wchar_t *wcsarg, int prec)
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include "floatio.h"
|
||||
#include "gdtoa.h"
|
||||
|
||||
#define DEFPREC 6
|
||||
|
||||
extern char *__dtoa(double, int, int, int *, int *, char **);
|
||||
extern void __freedtoa(char *);
|
||||
static int exponent(char *, int, int);
|
||||
#endif /* FLOATING_POINT */
|
||||
|
||||
@ -399,7 +398,7 @@ __vfprintf(FILE *fp, const char *fmt0, __va_list ap)
|
||||
flags&PTRINT ? GETARG(ptrdiff_t) : \
|
||||
flags&SIZEINT ? GETARG(ssize_t) : \
|
||||
flags&SHORTINT ? (short)GETARG(int) : \
|
||||
flags&CHARINT ? (__signed char)GETARG(int) : \
|
||||
flags&CHARINT ? (signed char)GETARG(int) : \
|
||||
GETARG(int)))
|
||||
#define UARG() \
|
||||
((uintmax_t)(flags&MAXINT ? GETARG(uintmax_t) : \
|
||||
@ -810,7 +809,7 @@ fp_common:
|
||||
else if (flags & SHORTINT)
|
||||
*GETARG(short *) = ret;
|
||||
else if (flags & CHARINT)
|
||||
*GETARG(__signed char *) = ret;
|
||||
*GETARG(signed char *) = ret;
|
||||
else if (flags & PTRINT)
|
||||
*GETARG(ptrdiff_t *) = ret;
|
||||
else if (flags & SIZEINT)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vfscanf.c,v 1.30 2013/04/17 17:40:35 tedu Exp $ */
|
||||
/* $OpenBSD: vfscanf.c,v 1.31 2014/03/19 05:17:01 guenther Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -273,7 +273,7 @@ literal:
|
||||
if (flags & SUPPRESS)
|
||||
continue;
|
||||
if (flags & SHORTSHORT)
|
||||
*va_arg(ap, __signed char *) = nread;
|
||||
*va_arg(ap, signed char *) = nread;
|
||||
else if (flags & SHORT)
|
||||
*va_arg(ap, short *) = nread;
|
||||
else if (flags & LONG)
|
||||
@ -749,7 +749,7 @@ literal:
|
||||
else if (flags & SHORT)
|
||||
*va_arg(ap, short *) = res;
|
||||
else if (flags & SHORTSHORT)
|
||||
*va_arg(ap, __signed char *) = res;
|
||||
*va_arg(ap, signed char *) = res;
|
||||
else
|
||||
*va_arg(ap, int *) = res;
|
||||
nassigned++;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vfwprintf.c,v 1.6 2013/04/17 17:40:35 tedu Exp $ */
|
||||
/* $OpenBSD: vfwprintf.c,v 1.9 2014/03/19 05:17:01 guenther Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
@ -54,8 +54,6 @@
|
||||
#include "local.h"
|
||||
#include "fvwrite.h"
|
||||
|
||||
wint_t __fputwc_unlock(wchar_t wc, FILE *fp);
|
||||
|
||||
union arg {
|
||||
int intarg;
|
||||
unsigned int uintarg;
|
||||
@ -235,11 +233,10 @@ __mbsconv(char *mbsarg, int prec)
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
#include "floatio.h"
|
||||
#include "gdtoa.h"
|
||||
|
||||
#define DEFPREC 6
|
||||
|
||||
extern char *__dtoa(double, int, int, int *, int *, char **);
|
||||
extern void __freedtoa(char *);
|
||||
static int exponent(wchar_t *, int, int);
|
||||
#endif /* FLOATING_POINT */
|
||||
|
||||
@ -392,7 +389,7 @@ __vfwprintf(FILE * __restrict fp, const wchar_t * __restrict fmt0, __va_list ap)
|
||||
flags&PTRINT ? GETARG(ptrdiff_t) : \
|
||||
flags&SIZEINT ? GETARG(ssize_t) : \
|
||||
flags&SHORTINT ? (short)GETARG(int) : \
|
||||
flags&CHARINT ? (__signed char)GETARG(int) : \
|
||||
flags&CHARINT ? (signed char)GETARG(int) : \
|
||||
GETARG(int)))
|
||||
#define UARG() \
|
||||
((uintmax_t)(flags&MAXINT ? GETARG(uintmax_t) : \
|
||||
@ -795,7 +792,7 @@ fp_common:
|
||||
else if (flags & SHORTINT)
|
||||
*GETARG(short *) = ret;
|
||||
else if (flags & CHARINT)
|
||||
*GETARG(__signed char *) = ret;
|
||||
*GETARG(signed char *) = ret;
|
||||
else if (flags & PTRINT)
|
||||
*GETARG(ptrdiff_t *) = ret;
|
||||
else if (flags & SIZEINT)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: vfwscanf.c,v 1.2 2012/01/18 17:23:11 chl Exp $ */
|
||||
/* $OpenBSD: vfwscanf.c,v 1.4 2014/03/19 05:17:01 guenther Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -31,7 +31,6 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
@ -300,7 +299,7 @@ literal:
|
||||
if (flags & SUPPRESS)
|
||||
continue;
|
||||
if (flags & SHORTSHORT)
|
||||
*va_arg(ap, __signed char *) = nread;
|
||||
*va_arg(ap, signed char *) = nread;
|
||||
else if (flags & SHORT)
|
||||
*va_arg(ap, short *) = nread;
|
||||
else if (flags & LONG)
|
||||
@ -324,7 +323,7 @@ literal:
|
||||
return (EOF);
|
||||
|
||||
default: /* compat */
|
||||
if (isupper(c))
|
||||
if (iswupper(c))
|
||||
flags |= LONG;
|
||||
c = CT_INT;
|
||||
base = 10;
|
||||
@ -672,7 +671,7 @@ literal:
|
||||
else if (flags & SHORT)
|
||||
*va_arg(ap, short *) = res;
|
||||
else if (flags & SHORTSHORT)
|
||||
*va_arg(ap, __signed char *) = res;
|
||||
*va_arg(ap, signed char *) = res;
|
||||
else
|
||||
*va_arg(ap, int *) = res;
|
||||
nassigned++;
|
||||
|
Loading…
Reference in New Issue
Block a user