aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Kroll III <henry@comptune.com>2010-10-27 03:44:00 -0700
committerHenry K <henry@desk.local>2010-10-27 03:54:12 -0700
commitfb498eb9257f4ac37e730b5af608e7812a4f63bf (patch)
tree1c6f20b33d399e0d8c6b7c8f05627f4c41813c5b
parent14673d0c49156b42c3cd04a86c36906f338c7fee (diff)
downloadtinycc-fb498eb9257f4ac37e730b5af608e7812a4f63bf.tar.gz
tinycc-fb498eb9257f4ac37e730b5af608e7812a4f63bf.tar.bz2
selinux: correct ftruncate, fix bus error in tcc -run
-rw-r--r--tccrun.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tccrun.c b/tccrun.c
index 24e1f95..0423a1d 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -38,12 +38,13 @@ int tcc_relocate(TCCState *s1)
{
int ret;
#ifdef HAVE_SELINUX
+ /* Use mmap instead of malloc for Selinux
+ Ref http://www.gnu.org/s/libc/manual/html_node/File-Size.html */
char tmpfname[] = "/tmp/.tccrunXXXXXX";
int fd = mkstemp (tmpfname);
- unlink (tmpfname); ftruncate (fd, 1000);
if ((ret= tcc_relocate_ex(s1,NULL)) < 0)return -1;
s1->mem_size=ret;
- /* Use mmap instead of malloc for Selinux */
+ unlink (tmpfname); ftruncate (fd, s1->mem_size);
s1->write_mem = mmap (NULL, ret, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, 0);
if(s1->write_mem == MAP_FAILED){