GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — - Added unpack limit. by redboltz · Pull Request #175 · msgpack/msgpack-c

Conversation

@redboltz

@redboltz redboltz commented Dec 14, 2014

Copy link
Copy Markdown
Contributor
  • Added new exceptions to explain limit over errors.
  • Fixed ext maximum size problem.
    Problem:
    The type of m_trail was uint32_t but when parsing ext, it could be 0xffffffff + 1. +1 means type. See https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family

Solution:
Modified the type of m_trail as std::size_t. If sizeof(std::size_t) == 4, 0xffffffff size of ext is an error. If sizeof(std::size_t) == 8, 0xffffffff size of ext is not an error. m_trail is 0xffffffff + 1.

Design cohice:
I chose std::size_t as the m_trail's type instead of uint64_t intentionally. On 64 addressing bit environment, there is no problem. On 32 bit environment, there is no problem except ext with maximum size. There is only one exception in the all msgpack format. Using uint64_t to support that, it's very expensive. On 32 addressing bit environment, allocating 0xffffffff + 1 bytes of memory couldn't succeed, so I believe that throwing an exception is a reasonable design choice in the case.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@redboltz
- Added unpack limit.
309e960
- Added new exceptions to explain limit over errors.

- Fixed ext maximum size problem.
Problem:
The type of m_trail was uint32_t but when parsing ext, it could be 0xffffffff + 1. +1 means type. See https://github.com/msgpack/msgpack/blob/master/spec.md#ext-format-family

Solution:
Modified the type of m_trail as std::size_t. If sizeof(std::size_t) == 4, 0xffffffff size of ext is an error. If sizeof(std::size_t) == 8, 0xffffffff size of ext is not an error. m_trail is 0xffffffff + 1.

Design cohice:
I chose std::size_t as the m_trail's type instead of uint64_t intentionally. On 64 addressing bit environment, there is no problem. On 32 bit environment, there is no problem except ext with maximum size. There is only one exception in the all msgpack format. Using uint64_t to support that, it's very expensive. On 32 addressing bit environment, allocating 0xffffffff + 1 bytes of memory couldn't succeed, so I believe that throwing an exception is a reasonable design choice in the case.
@redboltz

redboltz commented Dec 14, 2014

Copy link
Copy Markdown
Contributor Author

This PR for #159

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@redboltz redboltz assigned nobu-k Dec 14, 2014
splinterofchaos
splinterofchaos reviewed Dec 14, 2014
View reviewed changes
Comment thread include/msgpack/unpack.hpp Outdated

@splinterofchaos splinterofchaos Dec 14, 2014

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd think it'd be more convenient to supply both overloads.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@redboltz redboltz Dec 15, 2014

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment. I agree with you.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@redboltz
Fixed exceptions' interface. On the C++11, both const char* and const…
469040b
… std::string& are supported.

Updated all exceptions relate to unpack take a message parameter. It is better to explain the exceptional situation in detail. So far, just passing the exceptions name.
nobu-k added a commit that referenced this pull request Jan 2, 2015
@nobu-k
Merge pull request #175 from redboltz/add_limit
ce96ca8
- Added unpack limit.
@nobu-k
nobu-k merged commit ce96ca8 into msgpack:master Jan 2, 2015
@nobu-k

nobu-k commented Jan 2, 2015

Copy link
Copy Markdown
Member

LGTM.

By the way, we can use EXPECT_THROW to check exceptions in tests (see here).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

redboltz added a commit to redboltz/msgpack-c that referenced this pull request Jan 5, 2019
@redboltz
Fixed msgpack#754.
709d6f4
Fixed `msgpack::object` packing visitor and equal comparison visitor.

NOTE:
In the function `visit_ext(const char* v, uint32_t size)`, v contains
type and size means buffer `v` size. See msgpack#175.
@redboltz redboltz mentioned this pull request Jan 5, 2019
Fixed #754. #755
Merged
@redboltz redboltz mentioned this pull request May 6, 2019
Fix for issue 775 #776
Merged
@redboltz redboltz mentioned this pull request Aug 26, 2023
Unable to unpack extension with UINT32_MAX bytes of data #1086
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@nobu-k nobu-k

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@redboltz @nobu-k @splinterofchaos
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.