Skip to content

Commit

Permalink
Merge pull request #2509 from SixLabors/backport/2501
Browse files Browse the repository at this point in the history
Backport #2501
  • Loading branch information
JimBobSquarePants committed Aug 11, 2023
2 parents 71d5316 + e0d14b1 commit d1b52a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ImageSharp/Formats/Pbm/BufferedReadStreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void SkipWhitespaceAndComments(this BufferedReadStream stream)
{
innerValue = stream.ReadByte();
}
while (innerValue != 0x0a);
while (innerValue is not 0x0a and not -0x1);

// Continue searching for whitespace.
val = innerValue;
Expand Down
12 changes: 12 additions & 0 deletions tests/ImageSharp.Tests/Formats/Pbm/PbmMetadataTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.

using System;
using System.IO;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Pbm;

using Xunit;
Expand Down Expand Up @@ -82,5 +84,15 @@ public void Identify_DetectsCorrectComponentType(string imagePath, PbmComponentT
Assert.NotNull(bitmapMetadata);
Assert.Equal(expectedComponentType, bitmapMetadata.ComponentType);
}

[Fact]
public void Identify_HandlesCraftedDenialOfServiceString()
{
byte[] bytes = Convert.FromBase64String("UDEjWAAACQAAAAA=");
IImageInfo info = Image.Identify(bytes);
Assert.Equal(default, info.Size());
IImageFormat format = Configuration.Default.ImageFormatsManager.FindFormatByFileExtension("pbm");
Assert.Equal("PBM", format.Name);
}
}
}

0 comments on commit d1b52a2

Please sign in to comment.