Skip to content

Commit

Permalink
libcmd/cmp: report read errors (Solaris patch 045-CR7025778)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
McDutchie committed Jan 8, 2021
1 parent e20db01 commit 4c75920
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/libcmd/cmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,16 @@ cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags, Sfo
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;
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)
Expand All @@ -181,6 +185,8 @@ cmp(const char* file1, Sfio_t* f1, const char* file2, Sfio_t* f2, int flags, Sfo
{
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;
Expand Down

0 comments on commit 4c75920

Please sign in to comment.