Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation crash in setIdTag in StopTransaction #231

Open
emilm opened this issue Feb 10, 2023 · 1 comment
Open

Validation crash in setIdTag in StopTransaction #231

emilm opened this issue Feb 10, 2023 · 1 comment

Comments

@emilm
Copy link
Contributor

emilm commented Feb 10, 2023

idtag in stoptransaction is optional , so ModelUtil.validate() will check string != null . If it is null, it will return false.
When ModelUtil.validate() returns false, then idTag.length() crashes. How many more cases of this could there be?

  /**
   * Optional. This contains the identifier which requested to stop the charging. It is optional
   * because a Charge Point may terminate charging without the presence of an idTag, e.g. in case of
   * a reset. A Charge Point SHALL send the idTag if known.
   *
   * @param idTag a String with max length 20
   */
  @XmlElement
  public void setIdTag(String idTag) {
    if (!ModelUtil.validate(idTag, 20)) {
      throw new PropertyConstraintException(idTag.length(), "Exceeded limit of 20 chars");
    }

    this.idTag = idTag;
  }

My proposal is to add if idTag != null && in the check:

  if (idTag != null && !ModelUtil.validate(idTag, 20)) { ... 
mmauksch added a commit to mmauksch/Java-OCA-OCPP that referenced this issue Aug 17, 2023
@mmauksch
Copy link
Contributor

Took the liberty of doing a quick pullrequest based on your suggestion :)

TVolden added a commit that referenced this issue Aug 18, 2023
…tioncrash

validate via test and use suggested fix from #231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants