@@ -311,17 +311,34 @@ DNSClass: DNSClass preference: preference mailExchange: mailExchange TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_TXT) { - OFData *textData = [OFData dataWithItems: &buffer[i] - count: dataLength]; + OFMutableArray *textStrings = [OFMutableArray array]; + + while (dataLength > 0) { + uint_fast8_t stringLength = buffer[i++]; + dataLength--; + + if (stringLength > dataLength) + @throw [OFInvalidServerReplyException + exception]; + + [textStrings addObject: + [OFData dataWithItems: buffer + i + count: stringLength]]; + + i += stringLength; + dataLength -= stringLength; + } + + [textStrings makeImmutable]; return [[[OFTXTDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass - textData: textData + textStrings: textStrings TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RECORD_TYPE_RP) { size_t j = i; OFString *mailbox = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS);