[前][次][番号順一覧][スレッド一覧]

ruby-changes:24704

From: usa <ko1@a...>
Date: Tue, 21 Aug 2012 17:32:12 +0900 (JST)
Subject: [ruby-changes:24704] usa:r36755 (trunk): * addr2line.c (fill_lines): need check and cast of the file size of

usa	2012-08-21 17:32:01 +0900 (Tue, 21 Aug 2012)

  New Revision: 36755

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36755

  Log:
    * addr2line.c (fill_lines): need check and cast of the file size of
      target binary because there are some platforms which off_t > size_t.

  Modified files:
    trunk/ChangeLog
    trunk/addr2line.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 36754)
+++ ChangeLog	(revision 36755)
@@ -1,3 +1,8 @@
+Tue Aug 21 17:29:56 2012  NAKAMURA Usaku  <usa@r...>
+
+	* addr2line.c (fill_lines): need check and cast of the file size of
+	  target binary because there are some platforms which off_t > size_t.
+
 Tue Aug 21 17:07:58 2012  URABE Shyouhei  <shyouhei@r...>
 
 	* .travis.yml (compiler): [experimental] clang support.
Index: addr2line.c
===================================================================
--- addr2line.c	(revision 36754)
+++ addr2line.c	(revision 36755)
@@ -1,6 +1,6 @@
 /**********************************************************************
 
-  addr2line.h -
+  addr2line.c -
 
   $Author$
 
@@ -458,9 +458,14 @@
 	fprintf(stderr, "lseek: %s\n", strerror(e));
 	return;
     }
+    if (filesize > SIZE_MAX) {
+	close(fd);
+	fprintf(stderr, "Too large file %s\n", binary_filename);
+	return;
+    }
     lseek(fd, 0, SEEK_SET);
     /* async-signal unsafe */
-    file = (char *)mmap(NULL, filesize, PROT_READ, MAP_SHARED, fd, 0);
+    file = (char *)mmap(NULL, (size_t)filesize, PROT_READ, MAP_SHARED, fd, 0);
     if (file == MAP_FAILED) {
 	int e = errno;
 	close(fd);
@@ -470,7 +475,7 @@
 
     current_line->fd = fd;
     current_line->mapped = file;
-    current_line->mapped_size = filesize;
+    current_line->mapped_size = (size_t)filesize;
 
     for (i = 0; i < num_traces; i++) {
 	const char *path;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]