Fix potential NULL pointer dereference in gdImageClone() #580
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.
This PR fix a bug in the gdImageClone(), which can be used to generate a DoS condition on servers running PHP linked with the affected versions.
This patch has been improved (with the addition of tests) by @cmb69 .
CVE assigned: CVE-2018-14553
Original patch description:
`From 1e9d4d8a14619b7721cf1fc48a2260c24457418a Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" cmbecker69@gmx.de
Date: Fri, 20 Jul 2018 10:59:01 +0200
Subject: [PATCH] Fix potential NULL pointer dereference in gdImageClone()
If the image which should be cloned has set any style, the current code
which copies the style manually would dereference a NULL pointer. We
can simply remove this manual copying, since a few lines later in the
function we're already calling gdImageSetStyle() to copy the style
data. We have to make sure, though, to appropriately set the stylePos.
This security bug has been reported by Fabio Cabral Pacheco who also
provided the basic patch.`