Date: Fri, 24 Jul 2015 18:01:09 +0000 From: "emaste (Ed Maste)" <phabric-noreply@FreeBSD.org> To: freebsd-toolchain@freebsd.org Subject: [Differential] [Closed] D2338: readelf: avoid division by zero for files with invalid sh_entsize Message-ID: <627afc60ec88d368400d3ad626d694d0@localhost.localdomain> In-Reply-To: <differential-rev-PHID-DREV-qcsywqhy33xvasn2kx4a-req@FreeBSD.org> References: <differential-rev-PHID-DREV-qcsywqhy33xvasn2kx4a-req@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--b1_627afc60ec88d368400d3ad626d694d0 Content-Type: text/plain; charset = "utf-8" Content-Transfer-Encoding: 8bit This revision was automatically updated to reflect the committed changes. Closed by commit rS285845: readelf: avoid division by zero on section entry size (authored by emaste). CHANGED PRIOR TO COMMIT https://reviews.freebsd.org/D2338?vs=7069&id=7269#toc REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D2338?vs=7069&id=7269 REVISION DETAIL https://reviews.freebsd.org/D2338 AFFECTED FILES head/contrib/elftoolchain/readelf/readelf.c EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: emaste, brooks Cc: brooks, freebsd-toolchain-list --b1_627afc60ec88d368400d3ad626d694d0 Content-Type: text/x-patch; charset=utf-8; name="D2338.7269.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="D2338.7269.patch" ZGlmZiAtLWdpdCBhL2hlYWQvY29udHJpYi9lbGZ0b29sY2hhaW4vcmVhZGVsZi9yZWFkZWxmLmMg Yi9oZWFkL2NvbnRyaWIvZWxmdG9vbGNoYWluL3JlYWRlbGYvcmVhZGVsZi5jCi0tLSBhL2hlYWQv Y29udHJpYi9lbGZ0b29sY2hhaW4vcmVhZGVsZi9yZWFkZWxmLmMKKysrIGIvaGVhZC9jb250cmli L2VsZnRvb2xjaGFpbi9yZWFkZWxmL3JlYWRlbGYuYwpAQCAtMjcsNiArMjcsNyBAQAogI2luY2x1 Z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bnRmKCIlMTJzJTI0cyUxOHMlMTBz JTZzXG4iLCAiTGlicmFyeSIsICJUaW1lIFN0YW1wIiwKIAkJICAgICJDaGVja3N1bSIsICJWZXJz aW9uIiwgIkZsYWdzIik7CiAJCWZvciAoaiA9IDA7ICh1aW50NjRfdCkgaiA8IHMtPnN6IC8gcy0+ ZW50c2l6ZTsgaisrKSB7CkBAIC00Mzk5LDcgKzQ0MzAsNyBAQAogZHVtcF9taXBzX3JlZ2luZm8o c3RydWN0IHJlYWRlbGYgKnJlLCBzdHJ1Y3Qgc2VjdGlvbiAqcykKIHsKIAlFbGZfRGF0YSAqZDsK LQlpbnQgZWxmZXJyOworCWludCBlbGZlcnIsIGxlbjsKIAogCSh2b2lkKSBlbGZfZXJybm8oKTsK IAlpZiAoKGQgPSBlbGZfcmF3ZGF0YShzLT5zY24sIE5VTEwpKSA9PSBOVUxMKSB7CkBAIC00NDEx LDkgKzQ0NDIsMTAgQEAKIAl9CiAJaWYgKGQtPmRfc2l6ZSA8PSAwKQogCQlyZXR1cm47CisJaWYg KCFnZXRfZW50X2NvdW50KHMsICZsZW4pKQorCQlyZXR1cm47CiAKLQlwcmludGYoIlxuU2VjdGlv biAnJXMnIGNvbnRhaW5zICVqdSBlbnRyaWVzOlxuIiwgcy0+bmFtZSwKLQkgICAgcy0+c3ogLyBz LT5lbnRzaXplKTsKKwlwcmludGYoIlxuU2VjdGlvbiAnJXMnIGNvbnRhaW5zICVkIGVudHJpZXM6 XG4iLCBzLT5uYW1lLCBsZW4pOwogCWR1bXBfbWlwc19vZGtfcmVnaW5mbyhyZSwgZC0+ZF9idWYs IGQtPmRfc2l6ZSk7CiB9CiAKCg== --b1_627afc60ec88d368400d3ad626d694d0--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?627afc60ec88d368400d3ad626d694d0>