[webkit-changes] [WebKit/WebKit] d5514a: [WK2] Drop use of fixed-width types for size value...

Žan Doberšek noreply at github.com
Fri Jan 27 08:36:02 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d5514afba482699970de2ac435d31bb1c7acfc0b
      https://github.com/WebKit/WebKit/commit/d5514afba482699970de2ac435d31bb1c7acfc0b
  Author: Žan Doberšek <zdobersek at igalia.com>
  Date:   2023-01-27 (Fri, 27 Jan 2023)

  Changed paths:
    M Source/WebKit/Platform/IPC/ArgumentCoders.cpp
    M Source/WebKit/Platform/IPC/ArgumentCoders.h

  Log Message:
  -----------
  [WK2] Drop use of fixed-width types for size values in ArgumentCoder specializations
https://bugs.webkit.org/show_bug.cgi?id=250777

Reviewed by Kimmo Kinnunen.

Instead of finding better or worse fixed-sized-type matches for size values in
different ArgumentCoder specializations, the types of those size values should
be used. This means simply encoding values of size_t or unsigned types.

The target type of the size value should be noted in the code, just to provide
the necessary context of what is being encoded and have it match the decoding
side. This means the size type is explicitly used either in any temporary
variable where the value is stored, or an additional static_cast is used to
explicitly specify the type when the value is passed to the stream insertion
operator.

This still leaves open the possibility of using mismatched types, i.e. the
size value type not matching what the encoding enforces. Some sort of validation
could be implemented in the encoder class to make sure no undesired narrowing
conversions occur.

* Source/WebKit/Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<CString>::encode):
(IPC::ArgumentCoder<CString>::decode):
(IPC::ArgumentCoder<String>::encode):
(IPC::decodeStringText):
(IPC::ArgumentCoder<String>::decode):
(IPC::ArgumentCoder<StringView>::encode):
* Source/WebKit/Platform/IPC/ArgumentCoders.h:

Canonical link: https://commits.webkit.org/259488@main




More information about the webkit-changes mailing list