Skip to content

Commit 4c75920

Browse files
committed
libcmd/cmp: report read errors (Solaris patch 045-CR7025778)
This change is pulled from here: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/045-CR7025778.patch src/lib/libcmd/cmp.c: - If a read error occurs, issue an error message.
1 parent e20db01 commit 4c75920

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib/libcmd/cmp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,16 @@ cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags, Sfo
164164
return ret;
165165
if (!(p1 = (unsigned char*)sfreserve(f1, SF_UNBOUND, 0)) || (c1 = sfvalue(f1)) <= 0)
166166
{
167+
if (sferror(f1))
168+
error(ERROR_exit(2), "read error on %s", file1);
167169
if ((e2 - p2) > 0 || sfreserve(f2, SF_UNBOUND, 0) && sfvalue(f2) > 0)
168170
{
169171
ret = 1;
170172
if (!(flags & CMP_SILENT))
171173
error(ERROR_exit(1), "EOF on %s", file1);
172174
}
175+
if (sferror(f2))
176+
error(ERROR_exit(2), "read error on %s", file2);
173177
return ret;
174178
}
175179
if (count > 0 && c1 > count)
@@ -181,6 +185,8 @@ cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags, Sfo
181185
{
182186
if (!(p2 = (unsigned char*)sfreserve(f2, SF_UNBOUND, 0)) || (c2 = sfvalue(f2)) <= 0)
183187
{
188+
if (sferror(f2))
189+
error(ERROR_exit(2), "read error on %s", file2);
184190
if (!(flags & CMP_SILENT))
185191
error(ERROR_exit(1), "EOF on %s", file2);
186192
return 1;

0 commit comments

Comments
 (0)