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

ASF GitHub Bot commented on HDFS-16029:
---------------------------------------

pan3793 commented on PR #8420:
URL: https://github.com/apache/hadoop/pull/8420#issuecomment-4234465804

   @balodesecurity, please strictly follow 
[pull_request_template](https://github.com/apache/hadoop/blob/trunk/.github/pull_request_template.md),
 especially, answer the question - whether the PR `"Contains content generated 
by <tool>"`, for more details, read [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html)




> Divide by zero bug in InstrumentationService.java
> -------------------------------------------------
>
>                 Key: HDFS-16029
>                 URL: https://issues.apache.org/jira/browse/HDFS-16029
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: libhdfs
>            Reporter: Yiyuan GUO
>            Priority: Major
>              Labels: easy-fix, pull-request-available, security
>
> In the file _lib/service/instrumentation/InstrumentationService.java,_ the 
> method 
>  _Timer.getValues_ has the following 
> [code|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/instrumentation/InstrumentationService.java#L236]:
> {code:java}
> long[] getValues() {
>     ......
>     int limit = (full) ? size : (last + 1);
>     ......
>     values[AVG_TOTAL] = values[AVG_TOTAL] / limit;
> }
> {code}
> The variable _limit_ is used as a divisor. However, its value may be equal to 
> _last + 1,_ which can be zero since _last_ is initialized to -1 in the 
> [constructor|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/instrumentation/InstrumentationService.java#L222]:
> {code:java}
> public Timer(int size) {
>     ...
>     last = -1;
> }
> {code}
> Thus, a divide by zero problem can happen.
>   



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to