s3: printing: Use auto-updating of offset in printing_pread_data() to remove offset...
authorJeremy Allison <jra@samba.org>
Tue, 1 May 2018 18:08:40 +0000 (11:08 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 4 May 2018 20:34:24 +0000 (22:34 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/printing/nt_printing.c

index 1a31199d6abb49fb759c4ae289cfb511b6d3cdcf..f4e2768e536cde0b2f54fe473f11dd32b84ab614 100644 (file)
@@ -732,9 +732,7 @@ static int get_file_version(files_struct *fsp,
 {
        char    *buf = NULL;
        ssize_t byte_count;
-       off_t pos;
-       off_t oret;
-       off_t in_pos = -1;
+       off_t in_pos = fsp->fh->pos;
 
        buf=(char *)SMB_MALLOC(DOS_HEADER_SIZE);
        if (buf == NULL) {
@@ -764,19 +762,7 @@ static int get_file_version(files_struct *fsp,
         * Skip OEM header (if any) and the
         * DOS stub to start of Windows header.
         */
-       pos = SVAL(buf,DOS_HEADER_LFANEW_OFFSET);
-       oret = SMB_VFS_LSEEK(fsp, pos, SEEK_SET);
-       if (oret == (off_t)-1) {
-               DBG_NOTICE("File [%s] too short, errno = %d\n",
-                       fname,
-                       errno);
-               /*
-                * Assume this isn't an error...
-                * the file just looks sort of like a PE/NE file.
-                */
-               goto no_version_info;
-       }
-       pos = oret; /* Update new position. */
+       in_pos = SVAL(buf,DOS_HEADER_LFANEW_OFFSET);
 
        /* Note: DOS_HEADER_SIZE and NE_HEADER_SIZE are incidentally same */
        byte_count = printing_pread_data(fsp, buf, &in_pos, NE_HEADER_SIZE);