[Bug 237740] dd(1) always report false error about lseek(2) after read(2) error with 'conv=noerror' / dd(1) wrongly lseek(2)ed input file on read(2) error with 'conv=noerror'

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat May 4 03:41:26 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237740

            Bug ID: 237740
           Summary: dd(1) always report false error about lseek(2) after
                    read(2) error with 'conv=noerror' / dd(1) wrongly
                    lseek(2)ed input file on read(2) error with
                    'conv=noerror'
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: msl0000023508 at gmail.com

Created attachment 204204
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=204204&action=edit
fix-dd-noerror-lseek.diff

Reporting 2 bugs in the same place.

In the latest revision 341257 of 'dd.c', at
https://svnweb.freebsd.org/base/head/bin/dd/dd.c?view=log , line 420, the error
condition should be 'lseek(...) == -1'. The code:
                        if (in.flags & ISSEEK &&
                            lseek(in.fd, (off_t)in.dbsz, SEEK_CUR))
should be:
                        if (in.flags & ISSEEK &&
                            lseek(in.fd, (off_t)in.dbsz, SEEK_CUR) == -1)


Another bug is, when a read(2) error occurred, read(2) may actually read
something and change the file position then returning -1; when this happens the
later lseek(2) call will over seeking the current position, skipping data that
unrelated to the first read(2) error.

The attached patch fix both bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list