# defender-security/6.3.0/lib/packages/MaxMind/Db/Reader/Util.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 6.3.0. 33 lines.

- Page: https://pluginprobe.com/plugins/defender-security/6.3.0/code/lib/packages/MaxMind/Db/Reader/Util.php
- Raw: https://pluginprobe.com/plugins/defender-security/6.3.0/raw/lib/packages/MaxMind/Db/Reader/Util.php
- Modified: 2026-09-29T07:49:52+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/defender-security/6.3.0/code/lib/packages/MaxMind/Db/Reader/Util.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace WP_DEFENDER_VENDOR\MaxMind\Db\Reader;

class Util
{
    /**
     * @param resource $stream
     */
    public static function read($stream, int $offset, int $numberOfBytes): string
    {
        if ($numberOfBytes === 0) {
            return '';
        }
        if (fseek($stream, $offset) === 0) {
            $value = fread($stream, $numberOfBytes);

            // We check that the number of bytes read is equal to the number
            // asked for. We use ftell as getting the length of $value is
            // much slower.
            if ($value !== false && ftell($stream) - $offset === $numberOfBytes) {
                return $value;
            }
        }

        throw new InvalidDatabaseException(
            'The MaxMind DB file contains bad data'
        );
    }
}

```
