Skip to content

Commit d1b52a2

Browse files
Merge pull request #2509 from SixLabors/backport/2501
Backport #2501
2 parents 71d5316 + e0d14b1 commit d1b52a2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/ImageSharp/Formats/Pbm/BufferedReadStreamExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static void SkipWhitespaceAndComments(this BufferedReadStream stream)
2929
{
3030
innerValue = stream.ReadByte();
3131
}
32-
while (innerValue != 0x0a);
32+
while (innerValue is not 0x0a and not -0x1);
3333

3434
// Continue searching for whitespace.
3535
val = innerValue;

tests/ImageSharp.Tests/Formats/Pbm/PbmMetadataTests.cs

+12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System;
45
using System.IO;
6+
using SixLabors.ImageSharp.Formats;
57
using SixLabors.ImageSharp.Formats.Pbm;
68

79
using Xunit;
@@ -82,5 +84,15 @@ public void Identify_DetectsCorrectComponentType(string imagePath, PbmComponentT
8284
Assert.NotNull(bitmapMetadata);
8385
Assert.Equal(expectedComponentType, bitmapMetadata.ComponentType);
8486
}
87+
88+
[Fact]
89+
public void Identify_HandlesCraftedDenialOfServiceString()
90+
{
91+
byte[] bytes = Convert.FromBase64String("UDEjWAAACQAAAAA=");
92+
IImageInfo info = Image.Identify(bytes);
93+
Assert.Equal(default, info.Size());
94+
IImageFormat format = Configuration.Default.ImageFormatsManager.FindFormatByFileExtension("pbm");
95+
Assert.Equal("PBM", format.Name);
96+
}
8597
}
8698
}

0 commit comments

Comments
 (0)