Make sure that sensible values are extracted from a raw header.
authorNick Clifton <nickc@redhat.com>
Fri, 24 Sep 1999 09:03:49 +0000 (09:03 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 24 Sep 1999 09:03:49 +0000 (09:03 +0000)
gprof/ChangeLog
gprof/gmon_io.c

index 2f490fbb6d40aed919664cbadbb87f3dd22113dd..ae5e9f439f46e5cdd5b148ad053b8b16cea1f06c 100644 (file)
@@ -1,3 +1,8 @@
+1999-09-24  Nick Clifton  <nickc@cygnus.com>
+
+       * gmon_io.c (gmon_out_read): Make sure that sensible values
+       are extracted from a raw header.
+
 1999-08-06  Ian Lance Taylor  <ian@zembu.com>
 
        From Brad Lucier <lucier@math.purdue.edu>:
index 067323cbc9f856520862a40b3e43472d13e7ad5d..7e0a1a0a81beaa3f69f433ed87cebffc23733505 100644 (file)
@@ -251,6 +251,15 @@ DEFUN (gmon_out_read, (filename), const char *filename)
           printf ("[gmon_out_read] samp_bytes %d hist_num_bins %d\n",
                   samp_bytes, hist_num_bins));
 
+      /* Make sure that we have sensible values.  */
+      if (samp_bytes < 0 || lowpc > highpc)
+        {
+          fprintf (stderr, 
+           _("%s: file '%s' does not appear to be in gmon.out format\n"),
+           whoami, filename);
+          done (1);
+        }
+
       if (hist_num_bins)
        {
          ++nhist;