From da67a2822220a7faf82a6cdd8dc0c28f75243202 Mon Sep 17 00:00:00 2001 From: Paragon Initiative Enterprises Date: Thu, 25 Jan 2018 21:36:41 -0500 Subject: [PATCH] Carve out more nuisances. --- src/Stream/MutableFile.php | 4 +++- src/Stream/ReadOnlyFile.php | 6 ++++-- src/Symmetric/Crypto.php | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Stream/MutableFile.php b/src/Stream/MutableFile.php index 8b4726a..6b0ed90 100644 --- a/src/Stream/MutableFile.php +++ b/src/Stream/MutableFile.php @@ -158,10 +158,10 @@ public function readBytes(int $num, bool $skipTests = false): string } elseif ($num === 0) { return ''; } - // @codeCoverageIgnoreEnd if (($this->pos + $num) > $this->stat['size']) { throw new CannotPerformOperation('Out-of-bounds read'); } + // @codeCoverageIgnoreEnd $buf = ''; $remaining = $num; do { @@ -250,9 +250,11 @@ public function writeBytes(string $buf, int $num = null): int // @codeCoverageIgnoreEnd $remaining = $num; do { + // @codeCoverageIgnoreStart if ($remaining <= 0) { break; } + // @codeCoverageIgnoreEnd $written = \fwrite($this->fp, $buf, $remaining); if ($written === false) { // @codeCoverageIgnoreStart diff --git a/src/Stream/ReadOnlyFile.php b/src/Stream/ReadOnlyFile.php index c0f312c..d8df2db 100644 --- a/src/Stream/ReadOnlyFile.php +++ b/src/Stream/ReadOnlyFile.php @@ -210,6 +210,7 @@ public function getSize(): int */ public function readBytes(int $num, bool $skipTests = false): string { + // @codeCoverageIgnoreStart if ($num < 0) { throw new CannotPerformOperation('num < 0'); } elseif ($num === 0) { @@ -219,16 +220,17 @@ public function readBytes(int $num, bool $skipTests = false): string throw new CannotPerformOperation('Out-of-bounds read'); } $buf = ''; + // @codeCoverageIgnoreEnd $remaining = $num; if (!$skipTests) { $this->toctouTest(); } do { + // @codeCoverageIgnoreStart if ($remaining <= 0) { - // @codeCoverageIgnoreStart break; - // @codeCoverageIgnoreEnd } + // @codeCoverageIgnoreEnd /** @var string $read */ $read = \fread($this->fp, $remaining); if (!\is_string($read)) { diff --git a/src/Symmetric/Crypto.php b/src/Symmetric/Crypto.php index fabead4..992ceff 100644 --- a/src/Symmetric/Crypto.php +++ b/src/Symmetric/Crypto.php @@ -185,12 +185,14 @@ public static function decryptWithAd( // Check the MAC first if (!self::verifyMAC( + // @codeCoverageIgnoreStart (string) $auth, (string) $version . (string) $salt . (string) $nonce . (string) $additionalData . (string) $encrypted, + // @codeCoverageIgnoreEnd $authKey, $config )) {