[
https://issues.apache.org/jira/browse/CB-135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16139556#comment-16139556
]
luke88 edited comment on CB-135 at 8/24/17 5:00 AM:
----------------------------------------------------
the "javascript" list should also be protected.
Javascript obfuscator https://javascript-obfuscator.org/
was (Author: luke88):
the "javascript" list should also be protected.
Protect javascript code https://javascript-obfuscator.org/
> Multithreaded access on CallbackServer javascript object
> --------------------------------------------------------
>
> Key: CB-135
> URL: https://issues.apache.org/jira/browse/CB-135
> Project: Apache Cordova
> Issue Type: Bug
> Components: cordova-android
> Affects Versions: 1.0.0, 1.2.0
> Reporter: Gwyn Judd
> Assignee: Bryce Curtis
> Fix For: 1.4.0
>
>
> Any access to the list of javascript statements for the callbackserver class
> is only partially protected by synchronized critical sections. The three main
> culprits are here:
> /**
> * Get the number of JavaScript statements.
> *
> * @return int
> */
> public int getSize() {
> int size = this.javascript.size();
> //System.out.println("getSize() = " + size);
> return size;
> }
>
> /**
> * Get the next JavaScript statement and remove from list.
> *
> * @return String
> */
> public String getJavascript() {
> if (this.javascript.size() == 0) {
> return null;
> }
> String statement = this.javascript.remove(0);
> //System.out.println("CallbackServer.getJavascript() = " +
> statement);
> if (this.javascript.size() == 0) {
> synchronized (this) {
> this.empty = true;
> }
> }
> return statement;
> }
>
> /**
> * Add a JavaScript statement to the list.
> *
> * @param statement
> */
> public void sendJavascript(String statement) {
>
> //System.out.println("CallbackServer.sendJavascript("+statement+")");
> this.javascript.add(statement);
> synchronized (this) {
> this.empty = false;
> this.notify();
> }
> }
> "this.javascript" is a LinkedList which is not synchronized. Therefore doing
> something like this "this.javascript.add(statement);" will not be thread safe
> and is likely to lead to corruption or other undefined behaviour.
> Obviously these methods are meant to be called in a multithreaded manner
> because of the existence of the synchronized blocks - the "javascript" list
> should also be protected.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]