Bug 211002

Summary: WebPasteboardProxy::getPasteboardStringsForType() and WebPasteboardProxy::readURLFromPasteboard() should check return value of SharedMemory::createHandle()
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebKit2Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, katherine_cheney, useafterfree, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 211542    
Bug Blocks:    
Attachments:
Description Flags
Patch v1
none
Patch none

Description David Kilzer (:ddkilzer) 2020-04-24 15:57:33 PDT
WebPasteboardProxy::getPasteboardStringsForType() and WebPasteboardProxy::readURLFromPasteboard() should check return value of SharedMemory::createHandle().

<rdar://problem/60103950>
Comment 1 David Kilzer (:ddkilzer) 2020-04-24 16:02:14 PDT
Created attachment 397525 [details]
Patch v1
Comment 2 David Kilzer (:ddkilzer) 2020-04-24 18:12:55 PDT
Comment on attachment 397525 [details]
Patch v1

This code is only used on Apple platforms, so adding cq+ and ignoring build errors on GTK and WPE ports.
Comment 3 EWS 2020-04-24 18:33:02 PDT
Committed r260689: <https://trac.webkit.org/changeset/260689>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 397525 [details].
Comment 4 Darin Adler 2020-04-25 10:29:56 PDT
Are we going to add WARN_UNUSED_RETURN to createHandle?
Comment 5 David Kilzer (:ddkilzer) 2020-04-26 20:16:11 PDT
(In reply to Darin Adler from comment #4)
> Are we going to add WARN_UNUSED_RETURN to createHandle?

Yes, after we fix all the individual issues.  Tracked by <rdar://problem/62274167>.
Comment 6 Darin Adler 2020-04-26 22:03:29 PDT
Great!
Comment 7 WebKit Commit Bot 2020-05-06 18:54:58 PDT
Re-opened since this is blocked by bug 211542
Comment 8 Kate Cheney 2020-09-01 11:05:44 PDT
Created attachment 407698 [details]
Patch
Comment 9 Kate Cheney 2020-09-01 11:11:04 PDT
Thanks for the review Wenson. Going to wait for EWS before I cq+.
Comment 10 David Kilzer (:ddkilzer) 2020-09-01 13:40:07 PDT
Comment on attachment 407698 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407698&action=review

> Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:217
> -    sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
> +    if (!sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly))
> +        return completionHandler({ });

To find all places where this return value should be changed (and to prevent this from being re-introduced), change this in Source/WebKit/Platform/SharedMemory.h:

    bool createHandle(Handle&, Protection);

To this:

    WARN_UNUSED_RETURN bool createHandle(Handle&, Protection);

Then fix all the warnings.  (Not necessary to do for this patch.)
Comment 11 David Kilzer (:ddkilzer) 2020-09-01 13:40:36 PDT
Comment on attachment 407698 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407698&action=review

>> Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:217
>> +        return completionHandler({ });
> 
> To find all places where this return value should be changed (and to prevent this from being re-introduced), change this in Source/WebKit/Platform/SharedMemory.h:
> 
>     bool createHandle(Handle&, Protection);
> 
> To this:
> 
>     WARN_UNUSED_RETURN bool createHandle(Handle&, Protection);
> 
> Then fix all the warnings.  (Not necessary to do for this patch.)

Aaaaaand...I should have read the comments first.  :)
Comment 12 Kate Cheney 2020-09-01 13:58:53 PDT
(In reply to David Kilzer (:ddkilzer) from comment #11)
> Comment on attachment 407698 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=407698&action=review
> 
> >> Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:217
> >> +        return completionHandler({ });
> > 
> > To find all places where this return value should be changed (and to prevent this from being re-introduced), change this in Source/WebKit/Platform/SharedMemory.h:
> > 
> >     bool createHandle(Handle&, Protection);
> > 
> > To this:
> > 
> >     WARN_UNUSED_RETURN bool createHandle(Handle&, Protection);
> > 
> > Then fix all the warnings.  (Not necessary to do for this patch.)
> 
> Aaaaaand...I should have read the comments first.  :)

It's a good reminder! I can tackle that next.
Comment 13 EWS 2020-09-01 15:56:24 PDT
Committed r266416: <https://trac.webkit.org/changeset/266416>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 407698 [details].