зеркало из https://github.com/github/ruby.git
sprintf.c: string limits
* sprintf.c (ruby__sfvwrite): use long instead of size_t due to string limits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f956ed1061
Коммит
f31bb33a3b
11
sprintf.c
11
sprintf.c
|
@ -1301,14 +1301,19 @@ ruby__sfvwrite(register rb_printf_buffer *fp, register struct __suio *uio)
|
|||
struct __siov *iov;
|
||||
VALUE result = (VALUE)fp->_bf._base;
|
||||
char *buf = (char*)fp->_p;
|
||||
size_t len, n;
|
||||
size_t blen = buf - RSTRING_PTR(result), bsiz = fp->_w;
|
||||
long len, n;
|
||||
long blen = buf - RSTRING_PTR(result), bsiz = fp->_w;
|
||||
|
||||
if (RBASIC(result)->klass) {
|
||||
rb_raise(rb_eRuntimeError, "rb_vsprintf reentered");
|
||||
}
|
||||
if ((len = uio->uio_resid) == 0)
|
||||
if (uio->uio_resid == 0)
|
||||
return 0;
|
||||
#if SIZE_MAX > LONG_MAX
|
||||
if (uio->uio_resid >= LONG_MAX)
|
||||
rb_raise(rb_eRuntimeError, "too big string");
|
||||
#endif
|
||||
len = (long)uio->uio_resid;
|
||||
CHECK(len);
|
||||
buf += blen;
|
||||
fp->_w = bsiz;
|
||||
|
|
Загрузка…
Ссылка в новой задаче