diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-06 06:55:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-06 06:55:30 +0000 |
commit | e240f49073d7f04eb513d4665b118ed8cdfdb864 (patch) | |
tree | a0054c3c8249454ed783ce6a1e8623d77c6028c4 | |
parent | 3a6c3a672feeafb46f682b68295dd9a13f5b4725 (diff) |
* transcode.c (load_transcoder_entry): concatenate paths directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | transcode.c | 9 |
2 files changed, 9 insertions, 4 deletions
@@ -1,4 +1,6 @@ -Tue Sep 6 13:15:44 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> +Tue Sep 6 15:55:24 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * transcode.c (load_transcoder_entry): concatenate paths directly. * encoding.c (load_encoding): predefined encoding names are safe. [ruby-dev:44469] [Bug #5279] diff --git a/transcode.c b/transcode.c index 482fb6bf17..44bed8b2d2 100644 --- a/transcode.c +++ b/transcode.c @@ -369,16 +369,19 @@ load_transcoder_entry(transcoder_entry_t *entry) if (entry->lib) { const char *lib = entry->lib; size_t len = strlen(lib); - char path[sizeof(transcoder_lib_prefix) + MAX_TRANSCODER_LIBNAME_LEN]; + size_t total_len = sizeof(transcoder_lib_prefix) - 1 + len; + char *path; VALUE fn; entry->lib = NULL; if (len > MAX_TRANSCODER_LIBNAME_LEN) return NULL; + fn = rb_str_new(0, total_len); + path = RSTRING_PTR(fn); memcpy(path, transcoder_lib_prefix, sizeof(transcoder_lib_prefix) - 1); - memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len + 1); - fn = rb_str_new2(path); + memcpy(path + sizeof(transcoder_lib_prefix) - 1, lib, len); + rb_str_set_len(fn, total_len); FL_UNSET(fn, FL_TAINT|FL_UNTRUSTED); OBJ_FREEZE(fn); if (!rb_require_safe(fn, rb_safe_level())) |