2007-03-15 Eric Blake <ebb9@byu.net>

* libc/stdio/local.h (cantwrite, FREEUB, FREELB): Make reentrant.
	(__smakebuf): Rename...
	(__smakebuf_r): to this.
	* libc/stdio/fvwrite.h (__swsetup_r): Rename, from __swsetup.
	* libc/stdio/makebuf.c (__smakebuf): Detect failed asprint
	allocation, then rename...
	(__smakebuf_r): ...to this and fix reentrancy.
	* libc/stdio/wsetup.c (__swsetup): Detect failed asprintf
	allocation, then rename...
	(__swsetup_r): ...to this and fix reentrancy.
	* libc/stdio/fseek.c (_fseek_r): Fix reentrancy.
	* libc/stdio/refill.c (__srefill_r): Likewise.
	* libc/stdio/fclose.c (_fclose_r): Likewise.
	* libc/stdio/fread.c (_fread_r): Likewise.
	* libc/stdio/freopen.c (_freopen_r): Likewise.
	* libc/stdio/wbuf.c (__swbuf_r): Likewise.
	* libc/stdio64/fseeko64.c (_fseeko64_r): Likewise.
	* libc/stdio/fvwrite.c (__sfvwrite_r): Set errno properly on
	failed asprintf allocation, and fix reentrancy.
	* libc/stdio/snprintf.c (snprintf, _snprintf_r): Report overflow,
	as required by POSIX.
	* libc/stdio/sniprintf.c (sniprintf, _sniprintf_r): Likewise.
	* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Likewise.
	* libc/stdio/vsniprintf.c (vsniprintf, _vsniprintf_r): Likewise.
This commit is contained in:
Jeff Johnston
2007-03-15 18:40:48 +00:00
parent e96d068ed3
commit 14ba5e14d9
17 changed files with 151 additions and 55 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1990, 2006 The Regents of the University of California.
* Copyright (c) 1990, 2006, 2007 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
@ -196,10 +196,10 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp),
fp->_bf._size = 0;
fp->_lbfsize = 0;
if (HASUB (fp))
FREEUB (fp);
FREEUB (ptr, fp);
fp->_ub._size = 0;
if (HASLB (fp))
FREELB (fp);
FREELB (ptr, fp);
fp->_lb._size = 0;
if (f < 0)