Security fix for CVE-2011-3874

This commit is a port of the patch supplied to issue 21681 in AOSP. It
fixes the zergrush security problem. I had to slightly modify the patch
applied by google.

https://code.google.com/p/android/issues/detail?id=21681
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-3874

This fixes issue 5910:
https://code.google.com/p/cyanogenmod/issues/detail?id=5910

Change-Id: Ic8f584f0a4bf4c0e05a209bc690b93a5363799cf
Merge "Security fix for CVE-2011-3874" into gingerbread