Date: Wed, 29 Jun 2005 15:06:52 -0400 (EDT) From: "Andrew R. Reiter" <arr@watson.org> To: freebsd-current@FreeBSD.org Subject: [CFT] NDIS optional header length related fixups Message-ID: <20050629145451.J85841@fledge.watson.org>
next in thread | raw e-mail | index | archive | help
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-2052280901-1120072012=:85841 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Calling NDIS -CURRENT users, Attached is a patch that should fix any possible issues with mis-calculating offsets or sizes when dealing with anything 'image_optional_header' related in the PE loading code. The reason for the patch is that the optional header can have a varying length due to the lack of requiring the existence of all the 'image_data_directory's to exist within a binary. As far as I can tell, most drivers tend to include all, but due to the basic idea that there can be less than IMAGE_DIRECTORY_ENTRIES_MAX data directories in the optional header, we should at least make an attempt at preemptively catch any bugs that might arise due to improper pointer calculation. If you could, please give it a run in your tree! The patch is also located at: http://www.watson.org/~arr/ndis_opthdrsz.diff I guess let me know if anyone has any problems with this working (or other). Cheers, Andrew -- Andrew R. Reiter arr@watson.org --0-2052280901-1120072012=:85841 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=ndis_opthdrsz.diff Content-Transfer-Encoding: BASE64 Content-ID: <20050629150652.S85841@fledge.watson.org> Content-Description: Content-Disposition: attachment; filename=ndis_opthdrsz.diff SW5kZXg6IHBlX3Zhci5oDQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQpSQ1Mg ZmlsZTogL2hvbWUvbmN2cy9zcmMvc3lzL2NvbXBhdC9uZGlzL3BlX3Zhci5o LHYNCnJldHJpZXZpbmcgcmV2aXNpb24gMS4xMw0KZGlmZiAtdSAtdSAtcjEu MTMgcGVfdmFyLmgNCi0tLSBwZV92YXIuaAkxMSBBcHIgMjAwNSAwMjowMjoz NCAtMDAwMAkxLjEzDQorKysgcGVfdmFyLmgJMjkgSnVuIDIwMDUgMTg6NDc6 NTgg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CAoKGNo YXIgKikmc2VjdF9oZHItPmlzaF9uYW1lLCBuYW1lKSkgew0K --0-2052280901-1120072012=:85841--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050629145451.J85841>