You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Draczech (via GitHub)" <gi...@apache.org> on 2024/02/28 12:04:26 UTC
[PR] IMAGING-373: Throw exception on invalid bitmap offset [commons-imaging]
Draczech opened a new pull request, #368:
URL: https://github.com/apache/commons-imaging/pull/368
Fix of an issue described in https://issues.apache.org/jira/projects/IMAGING/issues/IMAGING-373
In case there are less bytes available in loaded image file than **bitmapPixelsOffset** says, an exception is thrown. New test case created with a broken ICO file to show how the problem is fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IMAGING-373: Throw exception on invalid bitmap offset [commons-imaging]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #368:
URL: https://github.com/apache/commons-imaging/pull/368
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IMAGING-373: Throw exception on invalid bitmap offset [commons-imaging]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #368:
URL: https://github.com/apache/commons-imaging/pull/368#issuecomment-1969224775
@Draczech
TY !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IMAGING-373: Throw exception on invalid bitmap offset [commons-imaging]
Posted by "Draczech (via GitHub)" <gi...@apache.org>.
Draczech commented on code in PR #368:
URL: https://github.com/apache/commons-imaging/pull/368#discussion_r1505992407
##########
src/test/java/org/apache/commons/imaging/formats/ico/IcoImageParserTest.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.imaging.formats.ico;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.apache.commons.imaging.ImagingException;
+import org.apache.commons.imaging.test.TestResources;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+
+public class IcoImageParserTest {
+
+ /**
+ * For https://issues.apache.org/jira/browse/IMAGING-373.
+ * <p> There is a problem with loading bitmap stored in given ICO file, so the exception is originally thrown by BmpImageParser.
Review Comment:
Fixed.
I haven't noticed any plugin like https://github.com/diffplug/spotless in the project, I might just missed it. Apparently I'm relying too much on such tools :)
##########
src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java:
##########
@@ -569,7 +569,7 @@ private BmpImageContents readImageContents(final InputStream is, final FormatCom
debugNumber("expectedDataOffset", expectedDataOffset, 4);
}
final int extraBytes = bhi.bitmapDataOffset - expectedDataOffset;
- if (extraBytes < 0) {
+ if ((extraBytes < 0) || (extraBytes > bhi.fileSize)) {
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IMAGING-373: Throw exception on invalid bitmap offset [commons-imaging]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #368:
URL: https://github.com/apache/commons-imaging/pull/368#discussion_r1505963612
##########
src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java:
##########
@@ -569,7 +569,7 @@ private BmpImageContents readImageContents(final InputStream is, final FormatCom
debugNumber("expectedDataOffset", expectedDataOffset, 4);
}
final int extraBytes = bhi.bitmapDataOffset - expectedDataOffset;
- if (extraBytes < 0) {
+ if ((extraBytes < 0) || (extraBytes > bhi.fileSize)) {
Review Comment:
No need for extra parens.
##########
src/test/java/org/apache/commons/imaging/formats/ico/IcoImageParserTest.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.imaging.formats.ico;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.apache.commons.imaging.ImagingException;
+import org.apache.commons.imaging.test.TestResources;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+
+public class IcoImageParserTest {
+
+ /**
+ * For https://issues.apache.org/jira/browse/IMAGING-373.
+ * <p> There is a problem with loading bitmap stored in given ICO file, so the exception is originally thrown by BmpImageParser.
Review Comment:
Close HTML tags. No need for a space after `<p>`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IMAGING-373: Throw exception on invalid bitmap offset [commons-imaging]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #368:
URL: https://github.com/apache/commons-imaging/pull/368#issuecomment-1968990774
## [Codecov](https://app.codecov.io/gh/apache/commons-imaging/pull/368?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `0%` with `1 lines` in your changes are missing coverage. Please review.
> Project coverage is 71.49%. Comparing base [(`fd2b5b8`)](https://app.codecov.io/gh/apache/commons-imaging/commit/fd2b5b8387d8f542e425c0c3f7d12f0706fe419d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`e4048b9`)](https://app.codecov.io/gh/apache/commons-imaging/pull/368?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> Report is 19 commits behind head on master.
| [Files](https://app.codecov.io/gh/apache/commons-imaging/pull/368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...he/commons/imaging/formats/bmp/BmpImageParser.java](https://app.codecov.io/gh/apache/commons-imaging/pull/368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2NvbW1vbnMvaW1hZ2luZy9mb3JtYXRzL2JtcC9CbXBJbWFnZVBhcnNlci5qYXZh) | 0.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/commons-imaging/pull/368?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #368 +/- ##
=========================================
Coverage 71.48% 71.49%
- Complexity 3580 3581 +1
=========================================
Files 352 352
Lines 16919 16905 -14
Branches 2648 2648
=========================================
- Hits 12095 12086 -9
+ Misses 3785 3780 -5
Partials 1039 1039
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/commons-imaging/pull/368?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org