reorder shm_put_var operations

Summary: Reordering the shm_put_var operation to serialize the object before
writing to memory aviods a segfault and possible arbitrary memory write.
Previously the shared memory location was found before the object was
serialized and it is possible to detach the shm location during serialization.
This would have shm_put_data write to memory using a shm handle that doesn't
exist.

CVE-2010-1861

Reviewed By: @markw65

Differential Revision: D1694899
fix for iconv_mime_decode_headers function skipping headers

Summary: A malformed mime header causes hhvm to punt on the rest of the
decode. This diff is a port of the fix for https://bugs.php.net/bug.php?id=52941
since the code is almost identical and solves the problem with embedded '=' and
'?' in mime headers.

CVE-2010-4699

Reviewed By: @JoelMarcey

Differential Revision: D1689385
Limit glob flags to only ones supported by php

Summary: PHP only lists support for a few glob flags. There was a segfault in
glob caused by passing invalid flags. To prevent that only allow php glob flags
to be used when calling glob.

CVE-2011-1657

Reviewed By: @paulbiss

Differential Revision: D1696172
make recursion limit for unserialize

Summary: This fixes a stack overflow caused by unlimited recursion in
unserialize. By checking the stack size, we avoid the stack overflow without
breaking anything else. There is no obvious way of running arbitrary code via
this, especially since all inputs to unserialize should be sanitized, but this
will close out this cve and prevent possible exploits.

CVE-2009-4418

Reviewed By: @bertmaher

Differential Revision: D1686292

Conflicts:
	hphp/runtime/base/thread-info.h
Update libmagic

Summary: Update libmagic to pull in fixes for various CVEs

CVE-2014-0207
CVE-2014-0237

Reviewed By: @JoelMarcey, @paulbiss

Differential Revision: D1713417
Update softmagic/libmagic

Summary: Fixes for upstream vulnerabilities/heap buffer overflows in file library

CVE-2014-3480
CVE-2014-3479
CVE-2014-3478

Reviewed By: @JoelMarcey

Differential Revision: D1715704
fixed decoding utf8 strings so they correctly return '?' on invalid sequences

Summary: fixed utf8 decode function so it will it will correctly handle invalid byte sequences. For example, the the old decoder allowed the non shortest form of a character to be decoded, which allows for a number of malicous attacks. Fixes #4442428, which is CVE-2010-3870 (Invalid UTF-8 passed to utf8_decode results in unexpected output)

Reviewed By: @ptarjan

Differential Revision: D1488851
Fix header injection

Summary: This is a minimal fix (suitable for hotfixing) for
the attached task.

Reviewed By: @jasone

Differential Revision: D1730314