How to create and apply patch diff in Asan Chromium?

231 views
Skip to first unread message

Adam White

unread,
Aug 29, 2021, 3:31:59 PM8/29/21
to Security-dev
How can I create and apply a patch.diff like in the report below? (Windows)

https://bugs.chromium.org/p/chromium/issues/detail?id=1161705

Thanks!

Adrian Taylor

unread,
Aug 29, 2021, 11:57:43 PM8/29/21
to Adam White, Security-dev
Hi

Creating a patch can be done using the UNIX "diff" command, and patches can be applied using the UNIX "patch" command. You can use cygwin or similar to get these commands on Windows. There are also python and GUI tool equivalents.

However, I usually use git. "git format-patch" can create patch files from git commits in your branch, and "git am" can be used to apply them. I must admit I haven't tried this on Windows, but I assume it will work the same way as on any other git platform.

If this doesn't do the trick, let us know and I expect some actual Windows user will reply :)

Adrian

Adam White

unread,
Aug 30, 2021, 12:44:32 PM8/30/21
to Security-dev, adet...@chromium.org, Security-dev, Adam White
Hi, thanks for your answer. I tried the git method you said but failed. I want to reproduce the following report:

For this I need to apply patch.diff. But I have no idea how to do this. Can you tell me what to do step by step?

Also a question: do I need to recompile Asan Chromium after applying patch.diff?

Thanks :)

30 Ağustos 2021 Pazartesi tarihinde saat 06:57:43 UTC+3 itibarıyla adet...@chromium.org şunları yazdı:

Ian Clelland

unread,
Aug 30, 2021, 4:47:30 PM8/30/21
to Adam White, Security-dev, adet...@chromium.org
On Mon, Aug 30, 2021 at 12:44 PM Adam White <samet...@gmail.com> wrote:
Hi, thanks for your answer. I tried the git method you said but failed. I want to reproduce the following report:

For this I need to apply patch.diff. But I have no idea how to do this. Can you tell me what to do step by step?

You won't be able to get precise step-by-step instructions, since your machine setup may be very different from anyone else's here. Much of this will be different depending on what OS you are using, for instance.
As Adrian said, the 'patch' command can be used to apply that diff file. On a UNIX-based system, you would generally run that from the command line (from the 'src' directory of your Chromium checkout) like

patch -p1 < patch.diff

but this may or may not succeed now, depending on how recent your checkout is. That patch file was generated from a specific chromium checkout at least eight months ago, and it might not apply now, depending on how much the surrounding code has changed in the meantime. In the worst case, you might need to figure out how to edit the code manually to produce the same effect.
 

Also a question: do I need to recompile Asan Chromium after applying patch.diff?

Yes, you will need to recompile after making changes to the source code.

It is usually easiest if you make sure that you have a working compile *before* you apply the diff, so that if compiling fails afterwards, you can at least narrow down the problem to just the changes that the diff introduced. 

Adrian Taylor

unread,
Aug 30, 2021, 6:15:16 PM8/30/21
to Adam White, Security-dev, Ian Clelland
Yes.

To emphasize what Ian says, absolutely do make sure you can build Chrome before doing anything at all with patch files. Building Chrome is a non-trivial endeavor. Here are the instructions for how to build Chrome.

Then figure out how to do an ASAN build.

Ideally, see if you can build the Chrome code from around the timeframe of that bug report. Only then, consider applying the patch and rebuilding.
Reply all
Reply to author
Forward
0 new messages