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

ASF GitHub Bot commented on MAPREDUCE-7447:
-------------------------------------------

teamconfx opened a new pull request, #6048:
URL: https://github.com/apache/hadoop/pull/6048

   ### Description of PR
   https://issues.apache.org/jira/browse/MAPREDUCE-7447
   This PR adds a null check for the key given when initializing a 
`CryptoOutputStream`.
   
   ### How was this patch tested?
   (1) set `mapreduce.job.encrypted-intermediate-data` to `true`
   (2) run 
`org.apache.hadoop.mapreduce.task.reduce.TestMergeManager#testLargeMemoryLimits`
   The test throws an `IllegalArgumentException` stating that the key given 
cannot be `null`.
   
   ### For code changes:
   
   - [x] Does the title or this PR starts with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?




> Unnecessary NPE encountered when starting CryptoOutputStream with 
> encrypted-intermediate-data
> ---------------------------------------------------------------------------------------------
>
>                 Key: MAPREDUCE-7447
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-7447
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>            Reporter: ConfX
>            Priority: Critical
>         Attachments: reproduce.sh
>
>
> h2. What happened?
> Got NullPointerException when initializing a {{{}CryptoOutputStream{}}}.
> h2. Where's the bug?
> In line 106 of {{{}CryptoOutputStream{}}},the code lacks a check to verify 
> whether the key parameter is null or not.
> {noformat}
> public CryptoOutputStream(OutputStream out, CryptoCodec codec,
>       int bufferSize, byte[] key, byte[] iv, long streamOffset,
>       boolean closeOutputStream)
>       throws IOException {
>      ...
>     this.key = key.clone();{noformat}
> As a result, when the configuration provides a null key, the key.clone() 
> operation will throw a NullPointerException.
> It is essential to add a null check for the key parameter before using it.
> h2. How to reproduce?
> (1) set {{mapreduce.job.encrypted-intermediate-data}} to {{true}}
> (2) run 
> {{org.apache.hadoop.mapreduce.task.reduce.TestMergeManager#testLargeMemoryLimits}}
> h2. Stacktrace
> h2. Stacktrace
> {noformat}
> java.lang.NullPointerException
>     at 
> org.apache.hadoop.crypto.CryptoOutputStream.<init>(CryptoOutputStream.java:106)
>     at 
> org.apache.hadoop.fs.crypto.CryptoFSDataOutputStream.<init>(CryptoFSDataOutputStream.java:38)
>     at 
> org.apache.hadoop.mapreduce.CryptoUtils.wrapIfNecessary(CryptoUtils.java:141)
>     at 
> org.apache.hadoop.mapreduce.security.IntermediateEncryptedStream.wrapIfNecessary(IntermediateEncryptedStream.java:46)
>     at 
> org.apache.hadoop.mapreduce.task.reduce.OnDiskMapOutput.<init>(OnDiskMapOutput.java:87)
>     at 
> org.apache.hadoop.mapreduce.task.reduce.MergeManagerImpl.reserve(MergeManagerImpl.java:274)
>     at 
> org.apache.hadoop.mapreduce.task.reduce.TestMergeManager.verifyReservedMapOutputType(TestMergeManager.java:309)
>     at 
> org.apache.hadoop.mapreduce.task.reduce.TestMergeManager.testLargeMemoryLimits(TestMergeManager.java:303){noformat}
> For an easy reproduction, run the reproduce.sh in the attachment.
> We are happy to provide a patch if this issue is confirmed.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: mapreduce-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: mapreduce-issues-h...@hadoop.apache.org

Reply via email to