diff --git a/NEWS b/NEWS index 36f955ebe..a3893089c 100644 --- a/NEWS +++ b/NEWS @@ -1,63 +1,93 @@ NEWS ---- -# User visible changes in `mruby3.2` +# User visible changes in `mruby3.3` from `mruby3.2` # The language -- Now `a::B = c` should evaluate `a` then `c`. -- Anonymous arguments `*`, `**`, `&` can be passed for forwarding. -- Multi-precision integer is available now via `mruby-bigint` gem. +- aliases work properly with `super` +- `callee` method work differently with aliases in mruby +- define `Kernel#respond_to_missing?` method +- `_inspect` method (`inspect` with recursive check) is removed +- `__printstr` method is removed; use `print` instead + +# Configuration + +- mruby can be built using Docker now. Try `docker-compose build` for example. +- New Platform: Nintendo Wii +- Improved Platforms: Android, Dreamcast + +# mruby memory API + +- `mrb_default_allocf` can be overridden by the application +- `mrb_open_allocf` will be deprecated # mruby VM and bytecode -- `OP_ARYDUP` was renamed to `OP_ARYSPLAT`. The instruction name - was changed but instruction number and basic behavior have not - changed (except that `ARYDUP nil` makes `[]`). +- [#5870](https://github.com/mruby/mruby/issues/5870) Use OP_LOADINEG instead of OP_LOADI -# Tools +# Changes in mrbgems -## `mruby` +- mruby-bin-config: new options --cxx,--cxxflags,--as,--asflags,--objc,--objcflags +- mruby-binding-eval (merged with mruby-eval) #5989 +- mruby-binding: renamed from mruby-binding-core +- mruby-enumerator: remove internal attribute methods obj, args, kwd, meth, fib. +- mruby-fiber: Add a new mrb_fiber_new() with MRB_API +- mruby-fiber: Allows calling `Fiber#resume` from C +- mruby-fiber: `Fiber#to_s` format changed +- mruby-io: Add "x" mode option for IO.open +- mruby-method: `Method#to_s` format changed +- mruby-pack: support new directives j,J,b,B +- mruby-range-ext: new method `Range#overlap?` +- mruby-string-ext: Add `String#valid_encoding?` method -- `-b` only specifies the script is the binary. The files loaded by `-r` are not affected by the option. -- `mruby` now loads complied binary if the suffix is `.mrb`. +# Bugs Fixed -## `mrbc` +- [#5712](https://github.com/mruby/mruby/issues/5712) No "make install" +- [#5724](https://github.com/mruby/mruby/issues/5724) Rational#** is missing +- [#5725](https://github.com/mruby/mruby/issues/5725) weird const_missing exceptions in mrblib code +- [#5789](https://github.com/mruby/mruby/issues/5789) No memory release of backtrace information due to stack error +- [#5943](https://github.com/mruby/mruby/issues/5943) TCPSocket#write is failed +- [#5944](https://github.com/mruby/mruby/issues/5944) Behavior of calling method with a hash variable +- [#5949](https://github.com/mruby/mruby/issues/5949) Caller appears to report wrong line when block passed and brackets omitted +- [#5974](https://github.com/mruby/mruby/issues/5974) Invalid escape sequences in gem_init.c on windows +- [#5975](https://github.com/mruby/mruby/issues/5975) Equals comparison fails on extreme ends of 64-bit integers +- [#5985](https://github.com/mruby/mruby/issues/5985) Sign extension with OP_LOADI32 in get_int_operand() +- [#5986](https://github.com/mruby/mruby/issues/5986) Fix bugs in String#bytesplice +- [#5987](https://github.com/mruby/mruby/issues/5987) ~(-1 << 64) is incorrect +- [#5991](https://github.com/mruby/mruby/issues/5991) 'gets' method not working in mruby-3.2.0 +- [#5995](https://github.com/mruby/mruby/issues/5995) One seemingly unnecessary parameter is passed in the block parameters +- [#6029](https://github.com/mruby/mruby/issues/6029) mruby build fails under mrbgems directory +- [#6041](https://github.com/mruby/mruby/issues/6041) GC Performance may have degraded +- [#6051](https://github.com/mruby/mruby/issues/6051) Null pointer dereference in mrb_addrinfo_unix_path +- [#6052](https://github.com/mruby/mruby/issues/6052) Null pointer dereference while handling the Proc class +- [#6065](https://github.com/mruby/mruby/issues/6065) Null pointer dereference while handling the Proc class +- [#6066](https://github.com/mruby/mruby/issues/6066) Null pointer dereference involving Struct.new() +- [#6067](https://github.com/mruby/mruby/issues/6067) Null pointer dereference in mrb_string_value_cstr +- [#6068](https://github.com/mruby/mruby/issues/6068) Stack overflow in mrb_vm_exec +- [#6087](https://github.com/mruby/mruby/issues/6087) 'Remote branch HEAD not found in upstream origin' error on build +- [#6089](https://github.com/mruby/mruby/issues/6089) binding.eval() handles def expressions differently from CRuby +- [#6098](https://github.com/mruby/mruby/issues/6098) Fails to call superclass of wrapped method +- [#6108](https://github.com/mruby/mruby/issues/6108) VM crashes with break +- [#6134](https://github.com/mruby/mruby/issues/6134) String#unpack1 returns an array instead of a single string -- Add `--no-optimize` option to disable optimization. +# Pull Requests (User Visible Ones) -# mrbgems - -## mruby-class-ext - -- Add `Class#subclasses` method. -- Add `Module#undefined_instance_methods` method. - -## New bundled gems - -- mruby-errno from [https://github.com/iij/mruby-errno.git] -- mruby-set from [https://github.com/yui-knk/mruby-set.git] -- mruby-dir from [https://github.com/iij/mruby-dir.git] - -# CVEs - -Following CVEs are fixed. - -- [CVE-2022-0080](https://nvd.nist.gov/vuln/detail/CVE-2022-0080) -- [CVE-2022-0240](https://nvd.nist.gov/vuln/detail/CVE-2022-0240) -- [CVE-2022-0326](https://nvd.nist.gov/vuln/detail/CVE-2022-0326) -- [CVE-2022-0481](https://nvd.nist.gov/vuln/detail/CVE-2022-0481) -- [CVE-2022-0525](https://nvd.nist.gov/vuln/detail/CVE-2022-0525) -- [CVE-2022-0570](https://nvd.nist.gov/vuln/detail/CVE-2022-0570) -- [CVE-2022-0614](https://nvd.nist.gov/vuln/detail/CVE-2022-0614) -- [CVE-2022-0623](https://nvd.nist.gov/vuln/detail/CVE-2022-0623) -- [CVE-2022-0630](https://nvd.nist.gov/vuln/detail/CVE-2022-0630) -- [CVE-2022-0631](https://nvd.nist.gov/vuln/detail/CVE-2022-0631) -- [CVE-2022-0632](https://nvd.nist.gov/vuln/detail/CVE-2022-0632) -- [CVE-2022-0717](https://nvd.nist.gov/vuln/detail/CVE-2022-0717) -- [CVE-2022-0890](https://nvd.nist.gov/vuln/detail/CVE-2022-0890) -- [CVE-2022-1106](https://nvd.nist.gov/vuln/detail/CVE-2022-1106) -- [CVE-2022-1212](https://nvd.nist.gov/vuln/detail/CVE-2022-1212) -- [CVE-2022-1276](https://nvd.nist.gov/vuln/detail/CVE-2022-1276) -- [CVE-2022-1286](https://nvd.nist.gov/vuln/detail/CVE-2022-1286) -- [CVE-2022-1934](https://nvd.nist.gov/vuln/detail/CVE-2022-1934) +- [#5870](https://github.com/mruby/mruby/pull/5870) Use OP_LOADINEG instead of OP_LOADI +- [#5966](https://github.com/mruby/mruby/pull/5966) Update default.gembox add mruby debugger mrdb +- [#5979](https://github.com/mruby/mruby/pull/5979) Allow Class#allocate to be prohibited +- [#5989](https://github.com/mruby/mruby/pull/5989) Integrate mruby-binding-eval into mruby-eval +- [#5961](https://github.com/mruby/mruby/pull/5961) Add Docker to build and run all mruby tests. Run pre-commit and generate YARD docs with Docker +- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory +- [#6009](https://github.com/mruby/mruby/pull/6009) Avoid adding /bintest which does not exist +- [#6012](https://github.com/mruby/mruby/pull/6012) Allow tests to be disabled for specific gems; warn about disabled tests +- [#6013](https://github.com/mruby/mruby/pull/6013) Fix Android toolchain +- [#6032](https://github.com/mruby/mruby/pull/6032) Rake: update task clean to remove bin and build folders +- [#6045](https://github.com/mruby/mruby/pull/6045) Fixes escape sequence bug and enhancements in Presym scanning +- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC +- [#6081](https://github.com/mruby/mruby/pull/6081) Add "x" mode option for IO.open +- [#6086](https://github.com/mruby/mruby/pull/6086) Add build config for Nintendo Wii +- [#6097](https://github.com/mruby/mruby/pull/6097) Add a new mrb_fiber_new() with MRB_API +- [#6106](https://github.com/mruby/mruby/pull/6106) Ease fiber limitations +- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf +- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails diff --git a/doc/mruby3.3.md b/doc/mruby3.3.md new file mode 100644 index 000000000..5fc5ca4eb --- /dev/null +++ b/doc/mruby3.3.md @@ -0,0 +1,90 @@ +# User visible changes in `mruby3.3` from `mruby3.2` + +# The language + +- aliases work properly with `super` +- `callee` method work differently with aliases in mruby +- define `Kernel#respond_to_missing?` method +- `_inspect` method (`inspect` with recursive check) is removed +- `__printstr` method is removed; use `print` instead + +# Configuration + +- mruby can be built using Docker now. Try `docker-compose build` for example. +- New Platform: Nintendo Wii +- Improved Platforms: Android, Dreamcast + +# mruby memory API + +- `mrb_default_allocf` can be overridden by the application +- `mrb_open_allocf` will be deprecated + +# mruby VM and bytecode + +- [#5870](https://github.com/mruby/mruby/issues/5870) Use OP_LOADINEG instead of OP_LOADI + +# Changes in mrbgems + +- mruby-bin-config: new options --cxx,--cxxflags,--as,--asflags,--objc,--objcflags +- mruby-binding-eval (merged with mruby-eval) #5989 +- mruby-binding: renamed from mruby-binding-core +- mruby-enumerator: remove internal attribute methods obj, args, kwd, meth, fib. +- mruby-fiber: Add a new mrb_fiber_new() with MRB_API +- mruby-fiber: Allows calling `Fiber#resume` from C +- mruby-fiber: `Fiber#to_s` format changed +- mruby-io: Add "x" mode option for IO.open +- mruby-method: `Method#to_s` format changed +- mruby-pack: support new directives j,J,b,B +- mruby-range-ext: new method `Range#overlap?` +- mruby-string-ext: Add `String#valid_encoding?` method + +# Bugs Fixed + +- [#5712](https://github.com/mruby/mruby/issues/5712) No "make install" +- [#5724](https://github.com/mruby/mruby/issues/5724) Rational#\*\* is missing +- [#5725](https://github.com/mruby/mruby/issues/5725) weird const_missing exceptions in mrblib code +- [#5789](https://github.com/mruby/mruby/issues/5789) No memory release of backtrace information due to stack error +- [#5943](https://github.com/mruby/mruby/issues/5943) TCPSocket#write is failed +- [#5944](https://github.com/mruby/mruby/issues/5944) Behavior of calling method with a hash variable +- [#5949](https://github.com/mruby/mruby/issues/5949) Caller appears to report wrong line when block passed and brackets omitted +- [#5974](https://github.com/mruby/mruby/issues/5974) Invalid escape sequences in gem_init.c on windows +- [#5975](https://github.com/mruby/mruby/issues/5975) Equals comparison fails on extreme ends of 64-bit integers +- [#5985](https://github.com/mruby/mruby/issues/5985) Sign extension with OP_LOADI32 in get_int_operand() +- [#5986](https://github.com/mruby/mruby/issues/5986) Fix bugs in String#bytesplice +- [#5987](https://github.com/mruby/mruby/issues/5987) ~(-1 << 64) is incorrect +- [#5991](https://github.com/mruby/mruby/issues/5991) 'gets' method not working in mruby-3.2.0 +- [#5995](https://github.com/mruby/mruby/issues/5995) One seemingly unnecessary parameter is passed in the block parameters +- [#6029](https://github.com/mruby/mruby/issues/6029) mruby build fails under mrbgems directory +- [#6041](https://github.com/mruby/mruby/issues/6041) GC Performance may have degraded +- [#6051](https://github.com/mruby/mruby/issues/6051) Null pointer dereference in mrb_addrinfo_unix_path +- [#6052](https://github.com/mruby/mruby/issues/6052) Null pointer dereference while handling the Proc class +- [#6065](https://github.com/mruby/mruby/issues/6065) Null pointer dereference while handling the Proc class +- [#6066](https://github.com/mruby/mruby/issues/6066) Null pointer dereference involving Struct.new() +- [#6067](https://github.com/mruby/mruby/issues/6067) Null pointer dereference in mrb_string_value_cstr +- [#6068](https://github.com/mruby/mruby/issues/6068) Stack overflow in mrb_vm_exec +- [#6087](https://github.com/mruby/mruby/issues/6087) 'Remote branch HEAD not found in upstream origin' error on build +- [#6089](https://github.com/mruby/mruby/issues/6089) binding.eval() handles def expressions differently from CRuby +- [#6098](https://github.com/mruby/mruby/issues/6098) Fails to call superclass of wrapped method +- [#6108](https://github.com/mruby/mruby/issues/6108) VM crashes with break +- [#6134](https://github.com/mruby/mruby/issues/6134) String#unpack1 returns an array instead of a single string + +# Pull Requests (User Visible Ones) + +- [#5870](https://github.com/mruby/mruby/pull/5870) Use OP_LOADINEG instead of OP_LOADI +- [#5966](https://github.com/mruby/mruby/pull/5966) Update default.gembox add mruby debugger mrdb +- [#5979](https://github.com/mruby/mruby/pull/5979) Allow Class#allocate to be prohibited +- [#5989](https://github.com/mruby/mruby/pull/5989) Integrate mruby-binding-eval into mruby-eval +- [#5961](https://github.com/mruby/mruby/pull/5961) Add Docker to build and run all mruby tests. Run pre-commit and generate YARD docs with Docker +- [#6008](https://github.com/mruby/mruby/pull/6008) Make "bintest" independent of directory +- [#6009](https://github.com/mruby/mruby/pull/6009) Avoid adding /bintest which does not exist +- [#6012](https://github.com/mruby/mruby/pull/6012) Allow tests to be disabled for specific gems; warn about disabled tests +- [#6013](https://github.com/mruby/mruby/pull/6013) Fix Android toolchain +- [#6032](https://github.com/mruby/mruby/pull/6032) Rake: update task clean to remove bin and build folders +- [#6045](https://github.com/mruby/mruby/pull/6045) Fixes escape sequence bug and enhancements in Presym scanning +- [#6076](https://github.com/mruby/mruby/pull/6076) Fixed unwinding block that could point to invalid PC +- [#6081](https://github.com/mruby/mruby/pull/6081) Add "x" mode option for IO.open +- [#6086](https://github.com/mruby/mruby/pull/6086) Add build config for Nintendo Wii +- [#6097](https://github.com/mruby/mruby/pull/6097) Add a new mrb_fiber_new() with MRB_API +- [#6106](https://github.com/mruby/mruby/pull/6106) Ease fiber limitations +- [#6118](https://github.com/mruby/mruby/pull/6118) Fixed IO#read with buf +- [#6120](https://github.com/mruby/mruby/pull/6120) Set EBADF if check_file_descriptor() fails diff --git a/mrbgems/mruby-pack/README.md b/mrbgems/mruby-pack/README.md index d108f2a09..2871fb4b3 100644 --- a/mrbgems/mruby-pack/README.md +++ b/mrbgems/mruby-pack/README.md @@ -45,7 +45,9 @@ There is no dependency on other mrbgems. - V : 32-bit unsigned, VAX (little-endian) byte order - v : 16-bit unsigned, VAX (little-endian) byte order - x : null byte +- X : back up bytes - Z : same as "a", except that null is added with \* +- @ : absolute position ## License diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c index 75d8e1a94..743b8663b 100644 --- a/mrbgems/mruby-pack/src/pack.c +++ b/mrbgems/mruby-pack/src/pack.c @@ -291,27 +291,24 @@ static void u64tostr(char *buf, size_t len, uint64_t n) { #ifdef MRB_NO_STDIO - char *bufend = buf + len; - char *p = bufend - 1; + mrb_assert(len > 0); - if (len < 1) { + if (n < 10) { + buf[0] = '0' + n; + buf[1] = '\0'; return; } + char *bufend = buf + len; + char *p = bufend - 1; + *p-- = '\0'; len--; - if (n > 0) { - for (; len > 0 && n > 0; len--, n /= 10) { - *p-- = '0' + (n % 10); - } - p++; + for (; len > 0 && n > 0; len--, n /= 10) { + *p-- = '0' + (n % 10); } - else if (len > 0) { - *p = '0'; - len--; - } - + p++; memmove(buf, p, bufend - p); #else snprintf(buf, len, "%" PRIu64, n); @@ -323,9 +320,7 @@ static void i64tostr(char *buf, size_t len, int64_t n) { #ifdef MRB_NO_STDIO - if (len < 1) { - return; - } + mrb_assert(len > 0); if (n < 0) { *buf++ = '-'; @@ -731,7 +726,7 @@ unpack_str(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count, CHECK_UNPACK_LEN(mrb, slen, ary); mrb_value dst; - const char *cp, *sptr; + const char *sptr; int copylen; sptr = (const char*)src; @@ -741,6 +736,8 @@ unpack_str(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count, copylen = slen; if (slen >= 0 && flags & PACK_FLAG_Z) { /* "Z" */ + const char *cp; + if ((cp = (const char*)memchr(sptr, '\0', slen)) != NULL) { copylen = (int)(cp - sptr); if (count == -1) { @@ -764,7 +761,6 @@ unpack_str(mrb_state *mrb, const void *src, int slen, mrb_value ary, int count, static int pack_hex(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, int count, unsigned int flags) { - int a, b; unsigned int ashift, bshift; long slen; char *dptr, *dptr0, *sptr; @@ -793,7 +789,8 @@ pack_hex(mrb_state *mrb, mrb_value src, mrb_value dst, mrb_int didx, int count, dptr0 = dptr; for (; count > 0; count -= 2) { - a = b = 0; + int a = 0, b = 0; + if (slen > 0) { a = hex2int(*sptr++); if (a < 0) break; @@ -1667,18 +1664,23 @@ pack_unpack(mrb_state *mrb, mrb_value str, int single) switch (dir) { case PACK_DIR_HEX: srcidx += unpack_hex(mrb, sptr, srclen - srcidx, result, count, flags); + if (single) goto single_return; continue; case PACK_DIR_BSTR: srcidx += unpack_bstr(mrb, sptr, srclen - srcidx, result, count, flags); + if (single) goto single_return; continue; case PACK_DIR_STR: srcidx += unpack_str(mrb, sptr, srclen - srcidx, result, count, flags); + if (single) goto single_return; continue; case PACK_DIR_BASE64: srcidx += unpack_base64(mrb, sptr, srclen - srcidx, result); + if (single) goto single_return; continue; case PACK_DIR_QENC: srcidx += unpack_qenc(mrb, sptr, srclen - srcidx, result); + if (single) goto single_return; continue; default: break; @@ -1729,6 +1731,7 @@ pack_unpack(mrb_state *mrb, mrb_value str, int single) } } if (single) { + single_return: if (RARRAY_LEN(result) > 0) { return RARRAY_PTR(result)[0]; } diff --git a/mrbgems/mruby-pack/test/pack.rb b/mrbgems/mruby-pack/test/pack.rb index 6045f788f..a3f110ba8 100644 --- a/mrbgems/mruby-pack/test/pack.rb +++ b/mrbgems/mruby-pack/test/pack.rb @@ -156,3 +156,18 @@ assert 'pack/unpack "U"' do assert_raise(RangeError) { [-1].pack("U") } assert_raise(RangeError) { [0x40000000].pack("U") } end + +assert 'unpack1' do + d = 1234 + assert_equal(d, [d].pack("i").unpack1("i")) + d = "foobar" + assert_equal(d, [d].pack("a*").unpack1("a*")) + assert_equal(d, [d].pack("A*").unpack1("A*")) + assert_equal(d, [d].pack("Z*").unpack1("Z*")) + assert_equal(d, [d].pack("m").unpack1("m")) + assert_equal(d, [d].pack("M").unpack1("M")) + d = "10010101" + assert_equal(d, [d].pack("b*").unpack1("b*")) + d = "f00b00" + assert_equal(d, [d].pack("h*").unpack1("h*")) +end