]> source.dussan.org Git - jgit.git/commitdiff
Ensure home directory not null before using in Sshdsessionfactory 57/204157/1
authorMinh Thai <mthai@google.com>
Wed, 6 Sep 2023 14:13:05 +0000 (07:13 -0700)
committerMinh Thai <mthai@google.com>
Wed, 6 Sep 2023 14:13:05 +0000 (07:13 -0700)
Home directory might not be set in DFS.

Change-Id: I3528685838065dc291826fc73a37126af7bf47ce

org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/transport/sshd/SshdSessionFactory.java

index 35c9be047ac15340647a2e6734992ba15a7ceb9c..cb2549e900881293f4efd4ab194cc150a4d52819 100644 (file)
@@ -244,11 +244,13 @@ public class SshdSessionFactory extends SshSessionFactory implements Closeable {
                                                        JGitSshClient.PREFERRED_AUTHENTICATIONS,
                                                        defaultAuths);
                                }
-                               try {
-                                       jgitClient.setAttribute(JGitSshClient.HOME_DIRECTORY,
-                                                       home.getAbsoluteFile().toPath());
-                               } catch (SecurityException | InvalidPathException e) {
+                               if (home != null && home.getAbsoluteFile() != null) {
+                                       try {
+                                               jgitClient.setAttribute(JGitSshClient.HOME_DIRECTORY,
+                                                               home.getAbsoluteFile().toPath());
+                                       } catch (SecurityException | InvalidPathException e) {
                                        // Ignore
+                                       }
                                }
                                // Other things?
                                return client;