Skip to content

Commit

Permalink
Merge pull request #6 from pic4xiu/master
Browse files Browse the repository at this point in the history
Program crashes when processing certain maliciously crafted images
  • Loading branch information
SimonWaldherr committed Jun 17, 2023
2 parents 8e9af9e + 0c8c6c6 commit c0d018f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zplgfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const (
// ConvertToZPL is just a wrapper for ConvertToGraphicField which also includes the ZPL
// starting code ^XA and ending code ^XZ, as well as a Field Separator and Field Origin.
func ConvertToZPL(img image.Image, graphicType GraphicType) string {
//Check before entering the ConvertToGraphicField function
//if the width is 0, the function can exit early
check := img.Bounds().Size().X / 8
if check == 0 {
return ""
}
return fmt.Sprintf("^XA,^FS\n^FO0,0\n%s^FS,^XZ\n", ConvertToGraphicField(img, graphicType))
}

Expand Down

0 comments on commit c0d018f

Please sign in to comment.