Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 6f01667

Browse files
committed
Merge branch 'jk/config-path-include-fix' into maint
include.path variable (or any variable that expects a path that can use ~username expansion) in the configuration file is not a boolean, but the code failed to check it. * jk/config-path-include-fix: handle_path_include: don't look at NULL value expand_user_path: do not look at NULL path
2 parents 34120a5 + 67beb60 commit 6f01667

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

config.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ static int handle_path_include(const char *path, struct config_include_data *inc
8484
{
8585
int ret = 0;
8686
struct strbuf buf = STRBUF_INIT;
87-
char *expanded = expand_user_path(path);
87+
char *expanded;
8888

89+
if (!path)
90+
return config_error_nonbool("include.path");
91+
92+
expanded = expand_user_path(path);
8993
if (!expanded)
9094
return error("Could not expand include path '%s'", path);
9195
path = expanded;

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ static struct passwd *getpw_str(const char *username, size_t len)
265265
char *expand_user_path(const char *path)
266266
{
267267
struct strbuf user_path = STRBUF_INIT;
268-
const char *first_slash = strchrnul(path, '/');
269268
const char *to_copy = path;
270269

271270
if (path == NULL)
272271
goto return_null;
273272
if (path[0] == '~') {
273+
const char *first_slash = strchrnul(path, '/');
274274
const char *username = path + 1;
275275
size_t username_len = first_slash - username;
276276
if (username_len == 0) {

0 commit comments

Comments
 (0)