ladybird/AK
Sergey Bugaev 1fb6a7d893 AK: Fix buffer overrun in Utf8CodepointIterator::operator++
The old implementation tried to move forward as long as the current
byte looks like a UTF-8 character continuation byte (has its two
most significant bits set to 10). This is correct as long as we assume
the string is actually valid UTF-8, which we do (we also have a separate
method that can check whether it is the case).

We can't, however, assume that the data after the end of our string
is also valid UTF-8 (in fact, we're not even allowed to look at data
outside out string, but it happens to a valid memory region most of
the time). If the byte after the end of our string also has its most
significant bits set to 10, we would move one byte forward, and then
fail the m_length > 0 assertion.

One way to fix this would be to add a length check inside the loop
condition. The other one, implemented in this commit, is to reimplement
the whole function in terms of decode_first_byte(), which gives us
the length as encoded in the first byte. This also brings it more
in line with the other functions around it that do UTF-8 decoding.
2019-09-08 17:45:10 +02:00
..
ELF Kernel: Support thread-local storage 2019-09-07 15:55:36 +02:00
Tests AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
Assertions.h TestSuite: Hijack the ASSERT macros during unit tests. 2019-08-02 09:23:03 +02:00
Badge.h AK: Delete the Badge copy and move constructors. 2019-06-11 23:47:51 -07:00
Bitmap.h AK: Make Bitmap movable but not copyable. 2019-08-01 11:34:36 +02:00
BufferStream.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
ByteBuffer.h ByteBuffer: Add slice_view(). Works like slice() but makes a wrapper only. 2019-07-27 15:26:51 +02:00
CircularQueue.h Add clang-format file 2019-05-28 17:31:20 +02:00
DoublyLinkedList.h AK: Defer to Traits<T> for equality comparison in container templates. 2019-06-29 19:14:03 +02:00
Error.h Add Error<> 2019-07-31 09:06:39 +02:00
FileSystemPath.cpp AK: Make FileSystemPath better at handling relative paths 2019-08-23 19:58:16 +02:00
FileSystemPath.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
FixedArray.h AK: Add a FixedArray<T> container 2019-08-07 20:05:36 +02:00
Function.h Add clang-format file 2019-05-28 17:31:20 +02:00
HashFunctions.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
HashMap.h AK: Add HashMap::find() with customizable finder callback 2019-08-25 06:45:27 +02:00
HashTable.h AK: Make HashTable.h compile inside the SDL2 port 2019-08-25 17:47:48 +02:00
InlineLinkedList.h AK: Add an iterator class for InlineLinkedList 2019-08-08 13:39:40 +02:00
InlineLRUCache.h AK: InlineLRUCache was always filling up one short of capacity. 2019-05-14 15:33:21 +02:00
install.sh Build: Install most headers to Root (and libcore.a/libgui.a) 2019-05-17 21:59:48 +02:00
IntrusiveList.h IntrusiveList: Make Iterator::operator* return a T& 2019-08-17 11:25:32 +02:00
IPv4Address.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
IterationDecision.h AK: Add IterationDecision.h. 2019-06-07 17:14:16 +02:00
JsonArray.cpp JSON: Templatize the JSON serialization code 2019-08-07 21:29:32 +02:00
JsonArray.h JSON: Port JsonArray and JsonObject serialization to serializers 2019-08-27 14:56:09 +02:00
JsonArraySerializer.h Json: Add serializer fast-path for string values 2019-09-04 14:40:11 +02:00
JsonObject.cpp JSON: Templatize the JSON serialization code 2019-08-07 21:29:32 +02:00
JsonObject.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
JsonObjectSerializer.h Json: Add serializer fast-path for string values 2019-09-04 14:40:11 +02:00
JsonParser.cpp JsonParser: "" is an empty string, not a null value 2019-08-14 15:01:42 +02:00
JsonParser.h JsonParser: Fold extract_while() into parse_number() 2019-08-04 20:23:46 +02:00
JsonValue.cpp JSON: Templatize the JSON serialization code 2019-08-07 21:29:32 +02:00
JsonValue.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
kmalloc.h Add clang-format file 2019-05-28 17:31:20 +02:00
kstdio.h Kernel+LibC: Add a dbgputstr() syscall for sending strings to debug output. 2019-07-21 21:43:37 +02:00
LogStream.cpp AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
LogStream.h LogStream: Prefix userspace dbg() output with "ProcessName(PID): " 2019-08-15 20:55:45 +02:00
MappedFile.cpp AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
MappedFile.h AK: Do not keep an open FD in MmappedFile 2019-08-05 16:04:31 +02:00
NetworkOrdered.h AK: Use __builtin_bswap() in NetworkOrdered. 2019-06-26 20:01:48 +02:00
Noncopyable.h Add clang-format file 2019-05-28 17:31:20 +02:00
NonnullOwnPtr.h AK: Use int_hash() to generate less idiotic hashes for {Nonnull,}OwnPtr 2019-08-14 21:21:15 +02:00
NonnullOwnPtrVector.h AK: Simplify NonnullPtrVector template a bit. 2019-07-25 11:10:28 +02:00
NonnullPtrVector.h NonnullPtrVector: Add ptr_at() getters for accessing the NonnullPtr 2019-08-19 19:04:52 +02:00
NonnullRefPtr.h AK: Simplify RefPtr and NonnullRefPtr's leak_ref() functions 2019-08-02 12:05:09 +02:00
NonnullRefPtrVector.h AK: Simplify NonnullPtrVector template a bit. 2019-07-25 11:10:28 +02:00
Optional.h AK: Optional::operator bool() should consume the Optional 2019-08-25 06:45:09 +02:00
OwnPtr.h AK: Use int_hash() to generate less idiotic hashes for {Nonnull,}OwnPtr 2019-08-14 21:21:15 +02:00
Platform.h AK: Shim open_with_path_length() for non-Serenity builds. 2019-07-25 14:25:45 +02:00
PrintfImplementation.h AK: Pad %b and %w to two and four places in printf 2019-09-08 08:49:29 +02:00
Queue.h AK: Add Queue::clear() to clear out a Queue. 2019-07-28 21:34:47 +02:00
QuickSort.h LibGUI: Run clang-format on everything. 2019-06-07 11:46:02 +02:00
RefCounted.h AK: Rename Retainable.h => RefCounted.h. 2019-06-21 18:58:45 +02:00
RefPtr.h AK: Make it possible to use HashMap<K, NonnullOwnPtr>::get() 2019-08-14 11:47:38 +02:00
Result.h Add Result<>, to use with/complement Error 2019-07-31 09:06:39 +02:00
ScopedValueRollback.h AK: Add ScopedValueRollback::set_override_rollback_value(). 2019-07-25 15:21:16 +02:00
ScopeGuard.h AK: ScopeGuard.h needs StdLibExtras.h 2019-06-18 09:31:14 +02:00
SinglyLinkedList.h AK: Add some missing includes in SinglyLinkedList. 2019-07-08 14:06:22 +02:00
StdLibExtras.h Kernel+AK: Remove AK/StdLibExtras.cpp, moving kernel stuff to Kernel/. 2019-07-29 11:58:44 +02:00
String.cpp AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
String.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
StringBuilder.cpp StringBuilder: Reset the internal builder length after building. 2019-07-08 15:57:25 +02:00
StringBuilder.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
StringImpl.cpp StringImpl: Fix possible uninitialized access in StringImpl::create(). 2019-06-24 14:38:44 +02:00
StringImpl.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
StringView.cpp AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
StringView.h AK: Add StringView::hash() 2019-08-25 06:45:31 +02:00
TemporaryChange.h Add clang-format file 2019-05-28 17:31:20 +02:00
TestSuite.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
Time.h AK: Make timeval_add() and timeval_sub() take references. 2019-06-06 18:02:28 +02:00
Traits.h AK: Make it possible to use HashMap<K, NonnullOwnPtr>::get() 2019-08-14 11:47:38 +02:00
Types.h AK: Add a useful align_up_to(value, power_of_two) function 2019-09-07 15:39:26 +02:00
URL.cpp AK: Add a basic URL class to help us handle URL's 2019-08-10 17:30:35 +02:00
URL.h AK: Rename <AK/AKString.h> to <AK/String.h> 2019-09-06 15:36:54 +02:00
Utf8View.cpp AK: Fix buffer overrun in Utf8CodepointIterator::operator++ 2019-09-08 17:45:10 +02:00
Utf8View.h Utf8View: Try fixing the travis-ci build 2019-09-05 19:06:39 +02:00
Vector.h Vector: Use memcpy to implement remove() for trivial types 2019-08-12 11:07:31 +02:00
Weakable.h AK: Rename Retainable.h => RefCounted.h. 2019-06-21 18:58:45 +02:00
WeakPtr.h AK: Remove use of copy_ref(). 2019-07-11 15:45:11 +02:00