commit 1bf2f1a06ee90cababf6787d589e91dd56a02852 from: Stefan Sperling date: Wed Dec 27 12:46:46 2023 UTC do not crash when a meta-data file in the .got directory is empty Reported by Matthias Schmidt ok tb@ commit - 65d7451409bf603e3c302b7d0ce999f7ce542508 commit + 1bf2f1a06ee90cababf6787d589e91dd56a02852 blob - cbce00f57c0999cd56f639776fdc0be83f732cf9 blob + 4b99863a5f6d3ae6dcce8b52c6d2a93a1a80b3d3 --- lib/worktree_open.c +++ lib/worktree_open.c @@ -78,6 +78,10 @@ read_meta_file(char **content, const char *path_got, c if (fstat(fd, &sb) != 0) { err = got_error_from_errno2("fstat", path); + goto done; + } + if (sb.st_size == 0) { + err = got_error_path(path, GOT_ERR_WORKTREE_META); goto done; } *content = calloc(1, sb.st_size);