WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
225335
Add bounds checks around calls to GlyphBuffer::stringOffsetAt()
https://bugs.webkit.org/show_bug.cgi?id=225335
Summary
Add bounds checks around calls to GlyphBuffer::stringOffsetAt()
Myles C. Maxfield
Reported
2021-05-03 16:36:04 PDT
Add bounds checks around calls to GlyphBuffer::stringOffsetAt()
Attachments
Patch
(2.63 KB, patch)
2021-05-03 17:07 PDT
,
Myles C. Maxfield
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(2.67 KB, patch)
2021-05-03 17:11 PDT
,
Myles C. Maxfield
simon.fraser
: review+
Details
Formatted Diff
Diff
Patch for committing
(6.81 KB, patch)
2021-05-08 15:47 PDT
,
Myles C. Maxfield
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch for committing
(6.83 KB, patch)
2021-05-08 15:52 PDT
,
Myles C. Maxfield
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2021-05-03 17:07:08 PDT
Created
attachment 427622
[details]
Patch
Myles C. Maxfield
Comment 2
2021-05-03 17:07:38 PDT
<
rdar://problem/75663608
>
Myles C. Maxfield
Comment 3
2021-05-03 17:11:48 PDT
Created
attachment 427624
[details]
Patch
Geoffrey Garen
Comment 4
2021-05-03 18:54:46 PDT
r=me too
Geoffrey Garen
Comment 5
2021-05-03 19:01:54 PDT
Comment on
attachment 427624
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=427624&action=review
> Source/WebCore/platform/graphics/WidthIterator.cpp:398 > auto stringOffset = glyphBuffer.stringOffsetAt(i);
Given the observation that stringOffsetAt may return an invalid value, indicating that CoreText did not find the string offset we wanted: (1) Can we just check for kCFNotFound (i.e., -1); that would be a lot more direct and clear. Do we benefit from this more abstract comparison here, and do we expect CoreText to return whacky values other than kCFNotFound for some reason? (2) Can stringOffsetAt return an Optional<GlyphBufferStringOffset> in order to become self-documenting? I don't think these questions block landing; but would be good to address.
Myles C. Maxfield
Comment 6
2021-05-08 15:24:47 PDT
Comment on
attachment 427624
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=427624&action=review
>> Source/WebCore/platform/graphics/WidthIterator.cpp:398 >> auto stringOffset = glyphBuffer.stringOffsetAt(i); > > Given the observation that stringOffsetAt may return an invalid value, indicating that CoreText did not find the string offset we wanted: > > (1) Can we just check for kCFNotFound (i.e., -1); that would be a lot more direct and clear. Do we benefit from this more abstract comparison here, and do we expect CoreText to return whacky values other than kCFNotFound for some reason? > > (2) Can stringOffsetAt return an Optional<GlyphBufferStringOffset> in order to become self-documenting? > > I don't think these questions block landing; but would be good to address.
(1) Given that these values can come from another framework, I think we should be defensive. (2) It can! Good idea.
Myles C. Maxfield
Comment 7
2021-05-08 15:47:41 PDT
Created
attachment 428094
[details]
Patch for committing
Myles C. Maxfield
Comment 8
2021-05-08 15:52:47 PDT
Created
attachment 428095
[details]
Patch for committing
EWS
Comment 9
2021-05-08 17:14:09 PDT
Committed
r277232
(
237501@main
): <
https://commits.webkit.org/237501@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 428095
[details]
.
Lauro Moura
Comment 10
2021-05-09 17:42:14 PDT
Comment on
attachment 428095
[details]
Patch for committing View in context:
https://bugs.webkit.org/attachment.cgi?id=428095&action=review
> Source/WebCore/platform/graphics/GlyphBuffer.h:81 > + if (result < 0 || static_cast<unsigned>(result) >= stringLength)
This is raising -Wtype-limits warnings on non-CG platforms due to GlyphBufferStringOffset being 'unsigned' there. What would be the proper way to silence them? Maybe move the result<0 comparison to a USE(CG) block? Example: In file included from WebCore/PrivateHeaders/WebCore/Font.h:30, from WebCore/PrivateHeaders/WebCore/FontCascade.h:28, from WebCore/PrivateHeaders/WebCore/GraphicsContext.h:32, from WebCore/PrivateHeaders/WebCore/FrameView.h:31, from ../../Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp:56: WebCore/PrivateHeaders/WebCore/GlyphBuffer.h: In member function ‘WTF::Optional<unsigned int> WebCore::GlyphBuffer::checkedStringOffsetAt(unsigned int, unsigned int) const’: WebCore/PrivateHeaders/WebCore/GlyphBuffer.h:81:20: warning: comparison of unsigned expression in ‘< 0’ is always false [-Wtype-limits] 81 | if (result < 0 || static_cast<unsigned>(result) >= stringLength) |
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug