You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Emmanuel Lécharny (Jira)" <ji...@apache.org> on 2024/10/28 18:31:00 UTC

[jira] [Commented] (DIRAPI-409) unchecked function result in JavaStoredProcUtils.java

    [ https://issues.apache.org/jira/browse/DIRAPI-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17893575#comment-17893575 ] 

Emmanuel Lécharny commented on DIRAPI-409:
------------------------------------------

I have added a check and throw an exception if the file read returns -1.

> unchecked function result in JavaStoredProcUtils.java
> -----------------------------------------------------
>
>                 Key: DIRAPI-409
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-409
>             Project: Directory Client API
>          Issue Type: Bug
>            Reporter: Alex
>            Priority: Minor
>
> if in.read(buf) returns -1, the try block will not work because the exception will not be raised.
> If in.read(buf) returns -1, it means that the end of the stream has been reached or an error occurred while reading (From the documentation: "If no bytes are available because the stream is at the end of the file, the value -1 is returned"). There will be no exception in this case
> There is no check in the getClassFileAsStream(Class<?> clazz) function that in.read(buf) returned -1.
> The function will continue executing the code and return the buf value.
> The finally block will fire, but in will be closed even if not all data has been read.
> This function is called in loadStoredProcedureClass( LdapContext ctx, Class<?> clazz), where there is also a check for the received buf value. That is, if the stream is at the end of the file, then the function will write "-1" instead of writing the byte code.
> It is necessary to add additional checks for the return value in.read(buf ).
> https://github.com/apache/directory-ldap-api/blob/ff9b56ecb984bdbed0f4df25da1485e8a4b4a870/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java#L72-L88



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@directory.apache.org
For additional commands, e-mail: dev-help@directory.apache.org