Modify

Opened 7 months ago

Last modified 7 months ago

#23708 new defect

String Index Out of Bounds in pt_assistant’s PublicTransportMendRelationAction.java#isRestricted

Reported by: guardian.oil Owned by: Biswesh
Priority: normal Milestone:
Component: Plugin pt_assistant Version:
Keywords: template_report Cc:

Description

What steps will reproduce the problem?

  1. Create a new route relation with:
    • "public_transport:version"="2"
    • "route"="bus"
    • "type"="route"
  2. Add these two ways to the relation:
    1. w622376397
    2. w1209377065
  3. Click the Routing Helper button.
  4. In the resulting How would you want the download to take place? dialog, choose On the fly > Yes.

What is the expected result?

The plugin does not crash.

What happens instead?

The plugin crashes with java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 11.

Please provide any additional information below. Attach a screenshot if possible.

The restrictions array at https://github.com/JOSM/pt_assistant/blob/698e43effe3616704befc45f8966d80944ff0ae9/src/main/java/org/openstreetmap/josm/plugins/pt_assistant/actions/mendrelation/PublicTransportMendRelationAction.java#L1105 gets passed into String.substring(12) at line 1126, but contains an 11-character string of "restriction".

Revision:19067
Build-Date:2024-05-02 13:15:27

Identification: JOSM/1.5 (19067 en) Mac OS X 14.5
OS Build number: macOS 14.5 (23F79)
Memory Usage: 440 MB / 16384 MB (198 MB allocated, but free)
Java version: 21.0.3+9-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel: com.apple.laf.AquaLookAndFeel
Screen: Display 3 2560×1440 (scaling 1.00×1.00) Display 4 2560×1440 (scaling 1.00×1.00)
Maximum Screen Size: 2560×1440
Best cursor sizes: 16×16→16×16, 32×32→32×32
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: en_CA
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Djpackage.app-version=19067, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, --add-exports=java.base/sun.security.action=ALL-UNNAMED, --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED, --add-opens=java.base/java.lang=ALL-UNNAMED, --add-opens=java.base/java.nio=ALL-UNNAMED, --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED, --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED, --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED, --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED, --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED, -Djpackage.app-path=/Applications/JOSM.app/Contents/MacOS/JOSM]
Dataset consistency test: No problems found

Plugins:
+ pt_assistant (633)

Map paint styles:
- https://josm.openstreetmap.de/josmfile?page=Styles/PublicTransport&zip=1

Last errors/warnings:
- 00001.124 W: PluginException: : org.openstreetmap.josm.plugins.PluginException: Invalid jar file '<josm.userdata>/plugins/ImproveOsm.jar.new'
- 00001.124 W: Failed to scan file 'ImproveOsm.jar.new' for plugin information. Skipping.
- 00001.218 W: Failed to install plugin '<josm.userdata>/plugins/ImproveOsm.jar' from temporary download file '<josm.userdata>/plugins/ImproveOsm.jar.new'. zip file is empty: java.util.zip.ZipException: zip file is empty
- 00012.581 W: java.util.zip.ZipException: zip file is empty
- 00012.582 W: PluginException: : org.openstreetmap.josm.plugins.PluginException: Invalid jar file '<josm.userdata>/plugins/ImproveOsm.jar.new'
- 00012.582 W: Failed to scan file 'ImproveOsm.jar.new' for plugin information. Skipping.
- 00030.130 E: Handled by bug report queue: java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 11
- 00036.742 W: java.util.zip.ZipException: zip file is empty
- 00036.742 W: PluginException: : org.openstreetmap.josm.plugins.PluginException: Invalid jar file '<josm.userdata>/plugins/ImproveOsm.jar.new'
- 00036.742 W: Failed to scan file 'ImproveOsm.jar.new' for plugin information. Skipping.



=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (40) of main
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 11
	at java.base/jdk.internal.util.Preconditions$1.apply(Unknown Source)
	at java.base/jdk.internal.util.Preconditions$1.apply(Unknown Source)
	at java.base/jdk.internal.util.Preconditions$4.apply(Unknown Source)
	at java.base/jdk.internal.util.Preconditions$4.apply(Unknown Source)
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Unknown Source)
	at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Unknown Source)
	at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source)
	at java.base/java.lang.String.substring(Unknown Source)
	at java.base/java.lang.String.substring(Unknown Source)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.lambda$isRestricted$25(PublicTransportMendRelationAction.java:1126)
	at java.base/java.util.ArrayList.removeIf(Unknown Source)
	at java.base/java.util.ArrayList.removeIf(Unknown Source)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.isRestricted(PublicTransportMendRelationAction.java:1109)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.lambda$removeInvalidWaysFromParentWays$16(PublicTransportMendRelationAction.java:938)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.removeInvalidWaysFromParentWays(PublicTransportMendRelationAction.java:938)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.findNextWay(PublicTransportMendRelationAction.java:765)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.findNextWayAfterDownload(PublicTransportMendRelationAction.java:599)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.downloadAreaAroundWay(PublicTransportMendRelationAction.java:1009)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.findNextWayBeforeDownload(PublicTransportMendRelationAction.java:591)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.callNextWay(PublicTransportMendRelationAction.java:320)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.downloadEntireArea(PublicTransportMendRelationAction.java:282)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.mendrelation.PublicTransportMendRelationAction.initialise(PublicTransportMendRelationAction.java:243)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.RoutingAction.callAction(RoutingAction.java:66)
	at org.openstreetmap.josm.plugins.pt_assistant.actions.RoutingAction.actionPerformed(RoutingAction.java:77)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Attachments (4)

Screenshot 2024-06-03 at 17.50.35.png (201.3 KB ) - added by guardian.oil 7 months ago.
Screenshot 2024-06-03 at 17.51.14.png (141.8 KB ) - added by guardian.oil 7 months ago.
Screenshot 2024-06-03 at 17.51.20.png (122.8 KB ) - added by guardian.oil 7 months ago.
Screenshot 2024-06-03 at 17.56.39.png (115.3 KB ) - added by guardian.oil 7 months ago.

Download all attachments as: .zip

Change History (5)

by guardian.oil, 7 months ago

by guardian.oil, 7 months ago

by guardian.oil, 7 months ago

by guardian.oil, 7 months ago

comment:1 by guardian.oil, 7 months ago

I opened a PR at https://github.com/JOSM/pt_assistant/pull/68 since the stacktrace points at an obvious fix.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Biswesh.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from Biswesh to the specified user.
Next status will be 'needinfo'. The owner will be changed from Biswesh to guardian.oil.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from Biswesh to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.