45 Commits

Author SHA1 Message Date
dearblue b7c8bf7781 Support MRB_DISABLE_STDIO for mruby-pack; ref #4954 2020-04-11 15:29:07 +09:00
dearblue 67606170e3 Add configuration guard for MRB_DISABLE_STDIO
ref #4576 and ref #4947

* Need MRBAPI functions without `MRB_DISABLE_STDIO`:
  * mrbgems/mruby-bin-debugger
  * mrbgems/mruby-bin-mirb
  * mrbgems/mruby-bin-mrbc
  * mrbgems/mruby-bin-mruby
  * mrbgems/mruby-bin-strip
* Need `stdio.h`:
  * mrbgems/mruby-io
  * mrbgems/mruby-print
* Need `snprintf()` in `stdio.h`:
  * mrbgems/mruby-pack
  * mrbgems/mruby-sprintf
2020-03-08 21:57:17 +09:00
dearblue cc1db2d117 Remove unnecessary 'stdio.h'; ref #4947
'stdio.h' is included in 'mruby.h' ('mrbconf.h').

However, keep 'stdio.h' used by mruby-test.
2020-03-08 21:42:09 +09:00
dearblue 56de911b7a Add "mruby developers" into some gems; Resolve #4709
It is writing side by side with the original authors.
2019-12-09 23:49:03 +09:00
dearblue 84d9296c05 Use inttypes for snprintf() 2019-09-25 23:28:05 +09:00
Yukihiro "Matz" Matsumoto 5a0204bb45 Remove unnecessary files from mruby-{io,pack,socket}. 2019-09-13 02:23:16 +09:00
KOBAYASHI Shuji 334afb167c Use new specifiers/modifiers of mrb_vfromat()
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in
my environment than before the introduction of new specifiers/modifiers
(5116789a) with this change.

  ------------+-------------------+-------------------+--------
   BINARY     | BEFORE (5116789a) |   AFTER (This PR) |  RATIO
  ------------+-------------------+-------------------+--------
   mruby      |      593416 bytes |      593208 bytes | -0.04%
   libmruby.a |      769048 bytes |      767264 bytes | -0.23%
  ------------+-------------------+-------------------+--------

BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613,
so I put it back.
2019-08-05 13:18:50 +09:00
KOBAYASHI Shuji 44381f0a0c Refine message to skip in nested assert
- I think "Info" is used only to `skip`, so change to "Skip".
- Changed the default value of `assert` and specify the argument explicitly
  at the caller of `assert` because it is unnatural "Assertion failed" is
  output even though the assertion doesn't fail.

== Example:

  def assert_foo(exp, act)
    assert do
      assert_equal exp[0], act[0]
      assert_equal exp[1], act[1]
    end
  end

  def assert_bar(exp, act)
    assert do
      skip
    end
  end

  def assert_baz(exp, act)
    assert do
      assert_equal exp, act
      assert_bar exp, act
    end
  end

  assert 'test#skip_in_nested_assert' do
    assert_baz 1, 1
  end

  === Before this patch:

    ?..
    Info: test#skip_in_nested_assert (core)
     - Assertion[1]
        Info: Assertion failed (core)
         - Assertion[1-2]
            Skip: Assertion failed (core)
      Total: 3
         OK: 2
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 1

  === After this patch:

    ???
    Skip: test#skip_in_nested_assert (core)
     - Assertion[1]
        Skip: assert (core)
         - Assertion[1-2]
            Skip: assert (core)
      Total: 3
         OK: 0
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 3
2019-07-30 13:05:01 +09:00
dearblue fd89948164 Fix empty array refers; ref #4556
For example, `"".unpack("")` evaluates to `[]`.
2019-07-14 12:03:44 +09:00
dearblue 4861be1171 Fix pack/unpack for base64; ref #4556
The pack/unpack "m" directive should be treated as a length rather than
an element count.
2019-07-14 12:03:00 +09:00
dearblue 109d926e9c Add pack/unpack test for base64 2019-07-15 10:41:32 +09:00
dearblue a215292b6a Use nested assert 2019-06-29 11:54:17 +09:00
Hiroshi Mimaki b630bf59ef Fix path of error.h. 2019-06-18 13:27:16 +09:00
KOBAYASHI Shuji ffc915fdee Fix missing assertions in mruby-pack test 2019-05-28 18:26:01 +09:00
Yukihiro "Matz" Matsumoto 7aff5507dd Avoid potential type mismatch warnings in pack.c. 2019-05-16 10:15:11 +09:00
Yukihiro "Matz" Matsumoto 2f14254142 Avoid potential integer overflow. 2019-05-16 10:13:52 +09:00
Yukihiro "Matz" Matsumoto a5a6b51126 Use uppercase version of ctype macros e.g. ISSPACE; fix #4338 2019-03-25 22:05:31 +09:00
KOBAYASHI Shuji 668d632c6e pack: Remove redundant float check in pack_utf8()
The argument is converted to fixnum before calling.
2019-01-03 19:11:30 +09:00
dearblue b7a832bf4f Define byte order macros, if not defined it and there are alternatives 2018-12-22 21:05:27 +09:00
Yukihiro "Matz" Matsumoto 445c64d0ad Fixed a bug on platforms without BYTE_ORDER; ref #4190 2018-12-21 09:26:48 +09:00
Yukihiro "Matz" Matsumoto 2fdb309e55 mruby-pack should not rely on MRB_ENDIAN_BIG macro; fix #4190
The `MRB_ENDIAN_BIG` macro is originally used for `NaN` boxing.
We cannot assume it is defined on every big endian platform (#4190
is the case). So instead of relying on untrusted `MRB_ENDIAN_BIG`, we
use `BYTE_ORDER` macro with a fallback function to check endian in
runtime.
2018-12-21 08:52:31 +09:00
Yukihiro "Matz" Matsumoto afca99a40b Remove implicit conversion using to_int method.
The ISO standard does not include implicit type conversion using
`to_int`. This implicit conversion often causes vulnerability.
There will be no more attacks like #4120.

In addition, we have added internal convenience method `__to_int` which
does type check and conversion (from floats).
2018-11-19 11:28:51 +09:00
Yukihiro "Matz" Matsumoto 7ad53273a2 Silence Appveyor's VC compilation warnings. 2018-11-01 22:52:12 +09:00
Yukihiro "Matz" Matsumoto 8b43754644 Use mrb_to_flo() to check return value from to_f; fix #4115
The ISO standard does not include implicit type conversion using
`to_int`, `to_str` and sometimes `to_f`. For the compactness of the
mruby implementation, maybe we should remove those implicit conversion
from mruby.
2018-09-18 09:35:09 +09:00
Yukihiro "Matz" Matsumoto 3447162a4c Add a new method unpack1 to mruby-pack gem. 2018-09-07 02:16:56 +09:00
Yukihiro "Matz" Matsumoto 04f8b0431c Fix heap buffer overflow in unpack_a; fix #4103 2018-09-07 02:15:55 +09:00
Yukihiro "Matz" Matsumoto a9abf65f03 Fixed wrong usages of mrb_raisef(); ref #4043
`mrb_raisef()` only takes `%S` specifier. If you don't have extra
arguments, use `mrb_raise()`.
2018-06-15 07:47:18 +09:00
Nobuhiro Iwamatsu 0759647f06 Fix test of mruby-pack with big-endian CPUs
When running the mruby-pack test with big endian, test data is incorrect,
so it will fail with "i" and "I".

------
Fail: pack/unpack "i" (mrbgems: mruby-pack)
 - Assertion[1] Failed: Expected to be equal
    Expected: "\xff\xff\xc7\xcf"
      Actual: "\xff\xff\xcf\xc7"
 - Assertion[2] Failed: Expected to be equal
    Expected: [-12345]
      Actual: [-14385]
Fail: pack/unpack "I" (mrbgems: mruby-pack)
 - Assertion[1] Failed: Expected to be equal
    Expected: "\x00\x0090"
      Actual: "\x00\x0009"
 - Assertion[2] Failed: Expected to be equal
    Expected: [12345]
      Actual: [14640]
------

This will fix the test data at big-endian.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
2018-05-10 12:54:08 +09:00
Yukihiro "Matz" Matsumoto a95b6d34aa Round up the dstlen value; fix #3949
The fix was proposed by https://hackerone.com/aerodudrizzt
2018-03-02 10:14:36 +09:00
Yukihiro "Matz" Matsumoto ef1a0e6358 Check sizeof(base64_dec_tab) in base64 encoding; fix #3947
The issue (and the fix) reported by https://hackerone.com/aerodudrizzt
2018-02-13 08:55:24 +09:00
Yukihiro "Matz" Matsumoto 7483753094 Check negative offset in pack method; fix #3944 2018-02-13 08:48:23 +09:00
Yukihiro "Matz" Matsumoto c5ec37a8ab Fixed wrong offset in pack_x function; ref #3944 2018-02-13 08:47:33 +09:00
Yukihiro "Matz" Matsumoto 00845ea908 Use 'mrb_raise instead of mrb_raisef` when no argument given. 2018-02-13 08:35:01 +09:00
Yukihiro "Matz" Matsumoto 79cfa377e1 Check negative count in pack_x and unpack_x; fix #3944 2018-02-10 16:59:14 +09:00
Yukihiro "Matz" Matsumoto 4c1494d58f Check if mruby-pack template count overflow; fix #3942 2018-02-09 12:55:13 +09:00
Hiroshi Mimaki 584e4e413a Added mrbgem's summary. 2017-12-13 16:05:06 +09:00
Yukihiro "Matz" Matsumoto c66978521d Reduce VC++ type mismatch warnings. 2017-12-13 08:10:35 +09:00
Yukihiro "Matz" Matsumoto d4ff92bcf6 Do not use FIXABLE when mrb_int is big enough. 2017-12-12 17:45:15 +09:00
Yukihiro "Matz" Matsumoto 3d98fa2e46 Reduce type mismatch warnings in pack.c. 2017-12-12 17:45:15 +09:00
Yukihiro "Matz" Matsumoto 08a508cbee Fixed the mixture of int and long in mruby-pack. 2017-12-12 09:48:53 +09:00
Yusuke Endoh d96b2c9a76 Support MRB_WITHOUT_FLOAT to mruby-io and mruby-pack 2017-12-12 00:47:56 +09:00
Yukihiro "Matz" Matsumoto b763759972 Reduce VC++ compiler warnings. 2017-12-11 17:22:46 +09:00
Yukihiro "Matz" Matsumoto 274884abe5 Reduce VC++ compiler warnings. 2017-12-09 16:14:12 +09:00
Yukihiro "Matz" Matsumoto b724e06cf2 Avoid uninitialized local variables in mruby-pack. 2017-12-07 20:28:30 +09:00
Yukihiro "Matz" Matsumoto a5412d48fd Add 'mrbgems/mruby-pack/' from commit '383a9c79e191d524a9a2b4107cc5043ecbf6190b'
git-subtree-dir: mrbgems/mruby-pack
git-subtree-mainline: 842e6945f2
git-subtree-split: 383a9c79e1
2017-12-07 18:35:09 +09:00