summaryrefslogtreecommitdiff
path: root/StdLib/LibC/Stdio/fgetstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'StdLib/LibC/Stdio/fgetstr.c')
-rw-r--r--StdLib/LibC/Stdio/fgetstr.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/StdLib/LibC/Stdio/fgetstr.c b/StdLib/LibC/Stdio/fgetstr.c
index 7364d3b891..9e898f3263 100644
--- a/StdLib/LibC/Stdio/fgetstr.c
+++ b/StdLib/LibC/Stdio/fgetstr.c
@@ -1,6 +1,13 @@
-/* $NetBSD: fgetstr.c,v 1.4 2006/11/24 19:46:58 christos Exp $ */
+/*
+ Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License that accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -30,20 +37,20 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+
+ $NetBSD: fgetstr.c,v 1.4 2006/11/24 19:46:58 christos Exp $
+ fgetline.c 8.1 (Berkeley) 6/4/93
+*/
+
+/*-
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)fgetline.c 8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: fgetstr.c,v 1.4 2006/11/24 19:46:58 christos Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -66,6 +73,10 @@ __slbexpand(FILE *fp, size_t newsize)
++newsize;
#endif
_DIAGASSERT(fp != NULL);
+ if(fp == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
if ((size_t)fp->_lb._size >= newsize)
return (0);
@@ -92,6 +103,10 @@ __fgetstr(FILE *fp, size_t *lenp, int sep)
_DIAGASSERT(fp != NULL);
_DIAGASSERT(lenp != NULL);
+ if(fp == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
/* make sure there is input */
if (fp->_r <= 0 && __srefill(fp)) {