From 4075dc19a8afcccab2417ba8df52e11a0e92715c Mon Sep 17 00:00:00 2001 From: Andrew Snow Date: Fri, 4 May 2012 19:57:21 +1000 Subject: [PATCH] Stop crash on binary files containing nulls --- ext/rubyfuse_lib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/rubyfuse_lib.c b/ext/rubyfuse_lib.c index db3056c..787438b 100644 --- a/ext/rubyfuse_lib.c +++ b/ext/rubyfuse_lib.c @@ -706,10 +706,9 @@ rf_open(const char *path, struct fuse_file_info *fi) { /* We have the body, now save it the entire contents to our * opened_file lists. */ newfile = ALLOC(opened_file); - value = StringValueCStr(body); - newfile->size = strlen(value); + newfile->size = RSTRING_LEN(body); newfile->value = ALLOC_N(char,(newfile->size)+1); - memcpy(newfile->value,value,newfile->size); + memcpy(newfile->value,RSTRING_PTR(body),newfile->size); newfile->value[newfile->size] = '\0'; newfile->writesize = 0; newfile->zero_offset = 0;