1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2011-09-06 06:55:30 +00:00
parent 3a6c3a672f
commit e240f49073
2 changed files with 9 additions and 4 deletions

View file

@ -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]

View file

@ -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()))