2010-04-12 Stan Shebs <stan@codesourcery.com>
authorStan Shebs <shebs@codesourcery.com>
Tue, 13 Apr 2010 03:53:50 +0000 (03:53 +0000)
committerStan Shebs <shebs@codesourcery.com>
Tue, 13 Apr 2010 03:53:50 +0000 (03:53 +0000)
* tracepoint.c (tfile_xfer_partial): Check read result.

gdb/ChangeLog
gdb/tracepoint.c

index 865768bea92442982a5c0e50c6b6d790667dbb0e..51cdaa6b4a29c08ad0d12c91697fb80db0164aaa 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-12  Stan Shebs  <stan@codesourcery.com>
+
+       * tracepoint.c (tfile_xfer_partial): Check read result.
+
 2010-04-12  Mike Frysinger  <vapier@gentoo.org>
 
        * remote-m32r-sdi.c (m32r_files_info): Add const to local "file" var.
index d3160a9336f4c66982b0d5f8f6bb0bdf696b40ae..82221826bdfcd7993a502b02fc0cfe459c514816 100644 (file)
@@ -3892,7 +3892,14 @@ tfile_xfer_partial (struct target_ops *ops, enum target_object object,
              if (amt > len)
                amt = len;
 
-             read (trace_fd, readbuf, amt);
+             gotten = read (trace_fd, readbuf, amt);
+             if (gotten < 0)
+               perror_with_name (trace_filename);
+             /* While it's acceptable to return less than was
+                originally asked for, it's not acceptable to return
+                less than what this block claims to contain.  */
+             else if (gotten < amt)
+               error (_("Premature end of file while reading trace file"));
              return amt;
            }
          lseek (trace_fd, mlen, SEEK_CUR);