components/ksh93/patches/CR7025778.patch
author Vladimir Marek <Vladimir.Marek@oracle.com>
Mon, 25 Nov 2013 17:42:18 +0100
branchs11u1-sru
changeset 2846 308d0c192664
parent 789 5f074ca23733
permissions -rw-r--r--
17714341 /usr/bin/cd core dumps during string substitution

--- a/src/lib/libcmd/cmp.c	Mon Apr 12 15:39:53 2010
+++ b/src/lib/libcmd/cmp.c	Tue Jun 28 13:59:47 2011
@@ -1,3 +1,7 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ */
+
 /***********************************************************************
 *                                                                      *
 *               This software is part of the ast package               *
@@ -164,6 +168,10 @@
 				return ret;
 			if (!(p1 = (unsigned char*)sfreserve(f1, SF_UNBOUND, 0)) || (c1 = sfvalue(f1)) <= 0)
 			{
+				if (sferror(f1)) {
+					error(ERROR_exit(2),
+					    "read error on %s", file1);
+				}
 				if ((e2 - p2) > 0 || sfreserve(f2, SF_UNBOUND, 0) && sfvalue(f2) > 0)
 				{
 					ret = 1;
@@ -170,6 +178,10 @@
 					if (!(flags & CMP_SILENT))
 						error(ERROR_exit(1), "EOF on %s", file1);
 				}
+				if (sferror(f2)) {
+					error(ERROR_exit(2),
+					    "read error on %s", file2);
+				}
 				return ret;
 			}
 			if (count > 0 && c1 > count)
@@ -181,6 +193,10 @@
 		{
 			if (!(p2 = (unsigned char*)sfreserve(f2, SF_UNBOUND, 0)) || (c2 = sfvalue(f2)) <= 0)
 			{
+				if (sferror(f2)) {
+					error(ERROR_exit(2),
+					    "read error on %s", file2);
+				}
 				if (!(flags & CMP_SILENT))
 					error(ERROR_exit(1), "EOF on %s", file2);
 				return 1;