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

Jan Hentschel commented on SENTRY-1657:
---------------------------------------

[~akolb] Can *commandClazz* really be null in the try-block? If *commandClazz* 
is null in the if-statement it will go to the *printHelp* method which exits 
with a 1 code.

{code:java}
private static void printHelp(Options options, String msg) {
    String sentry = "sentry";
    if (msg != null) {
      sentry = msg + sentry;
    }
    (new HelpFormatter()).printHelp(sentry, options);
    System.exit(1);
  }
{code}

> Possible null-pointer dereference in SentryMain
> -----------------------------------------------
>
>                 Key: SENTRY-1657
>                 URL: https://issues.apache.org/jira/browse/SENTRY-1657
>             Project: Sentry
>          Issue Type: Bug
>          Components: Sentry
>    Affects Versions: 1.8.0
>            Reporter: Alexander Kolbasov
>            Priority: Minor
>              Labels: bite-sized, newbie
>
> In SentryMain.java there is the following code:
> {code}
>     String commandClazz = COMMANDS.get(commandName);
>     if (commandClazz == null) { // may be null here
>       printHelp(options, "Unknown command " + commandName + "\n");
>     }
>     Object command;
>     try {
>       command = Class.forName(commandClazz.trim()).newInstance(); // 
> dereference null here
> ...
> {code}
> Note that commandClazz may be null and yet be dereferenced.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to