diff options
author | Jeremy Allison <jra@samba.org> | 2018-05-01 11:16:02 -0700 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2018-05-04 22:34:24 +0200 |
commit | a87328edee55c4e71b468da8642689bb24b6bb1d (patch) | |
tree | 9ac6fadb986a5b78f4ce6ab2f3ecc9c7f94efbb0 /source3/printing | |
parent | 0c736ae06821b46ca4c541982de3cf8af48c50ba (diff) | |
download | samba-a87328edee55c4e71b468da8642689bb24b6bb1d.tar.gz |
s3: printing: Use passed in offset, and offset tracking in printing_pread_data() to remove seeks from handle_pe_file().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/nt_printing.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 8c73b52801a..dbcf71a4cdb 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -374,7 +374,7 @@ static ssize_t printing_pread_data(files_struct *fsp, ****************************************************************************/ static int handle_pe_file(files_struct *fsp, - off_t in_pos_unused, + off_t in_pos, char *fname, char *buf, uint32_t *major, @@ -384,23 +384,18 @@ static int handle_pe_file(files_struct *fsp, unsigned int num_sections; unsigned int section_table_bytes; ssize_t byte_count; - off_t oret; - off_t pos; - off_t in_pos = -1; + off_t rel_pos; int ret = -1; /* Just skip over optional header to get to section table */ - pos = SVAL(buf,PE_HEADER_OPTIONAL_HEADER_SIZE)- + rel_pos = SVAL(buf,PE_HEADER_OPTIONAL_HEADER_SIZE)- (NE_HEADER_SIZE-PE_HEADER_SIZE); - oret = SMB_VFS_LSEEK(fsp, pos, SEEK_CUR); - if (oret == (off_t)-1) { - DBG_NOTICE("File [%s] Windows optional header " - "too short, errno = %d\n", - fname, - errno); + if (in_pos + rel_pos < in_pos) { + /* Integer wrap. */ goto out; } + in_pos = rel_pos + in_pos; /* get the section table */ num_sections = SVAL(buf,PE_HEADER_NUMBER_OF_SECTIONS); @@ -459,19 +454,10 @@ static int handle_pe_file(files_struct *fsp, } /* - * Seek to the start of the .rsrc + * Read from the start of the .rsrc * section info */ - oret = SMB_VFS_LSEEK(fsp, - section_pos, - SEEK_SET); - if (oret == (off_t)-1) { - DBG_NOTICE("PE file [%s] too short for " - "section info, errno = %d\n", - fname, - errno); - goto out; - } + in_pos = section_pos; byte_count = printing_pread_data(fsp, buf, |