Commit 14d7583
config: remove unneeded struct field
As well as receiving the config key and value, config callbacks
also receive a "struct key_value_info" containing information about
the source of the key-value pair. Accessing the "path" field of
this struct from a callback passed to repo_config() results in a
use-after-free. This happens because repo_config() first populates a
configset by calling config_with_options() and then iterates over the
configset with the callback passed by the caller. When the configset
is constructed it takes a shallow copy of the "struct key_value_info"
for each config setting. This leads to the use-after-free as the
"path" member is freed before config_with_options() returns.
We could fix this by interning the "path" field as we do
for the "filename" field but the "path" field is not actually
needed. It is populated with a copy of the "path" field from "struct
config_source". That field was added in d14d424 (config: disallow
relative include paths from blobs, 2014-02-19) to distinguish between
relative include directives in files and those in blobs. However,
since 1b8132d (i18n: config: unfold error messages marked for
translation, 2016-07-28) we can differentiate these by looking at the
"origin_type" field in "struct key_value_info". So let's remove the
"path" members from "struct config_source" and "struct key_value_info"
and instead use a combination of the "filename" and "origin_type"
fields to determine the absolute path of relative includes.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 16bd9f2 commit 14d7583
2 files changed
+13
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
| |||
173 | 172 | | |
174 | 173 | | |
175 | 174 | | |
176 | | - | |
| 175 | + | |
177 | 176 | | |
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
181 | | - | |
| 180 | + | |
182 | 181 | | |
183 | | - | |
| 182 | + | |
184 | 183 | | |
185 | 184 | | |
186 | 185 | | |
| |||
224 | 223 | | |
225 | 224 | | |
226 | 225 | | |
227 | | - | |
| 226 | + | |
228 | 227 | | |
229 | 228 | | |
230 | 229 | | |
231 | | - | |
| 230 | + | |
232 | 231 | | |
233 | 232 | | |
234 | 233 | | |
| |||
633 | 632 | | |
634 | 633 | | |
635 | 634 | | |
636 | | - | |
637 | 635 | | |
638 | 636 | | |
639 | 637 | | |
| |||
1036 | 1034 | | |
1037 | 1035 | | |
1038 | 1036 | | |
1039 | | - | |
1040 | 1037 | | |
1041 | 1038 | | |
1042 | 1039 | | |
| |||
1855 | 1852 | | |
1856 | 1853 | | |
1857 | 1854 | | |
1858 | | - | |
1859 | | - | |
| 1855 | + | |
| 1856 | + | |
1860 | 1857 | | |
1861 | 1858 | | |
1862 | 1859 | | |
1863 | 1860 | | |
1864 | 1861 | | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
1865 | 1865 | | |
1866 | 1866 | | |
1867 | 1867 | | |
1868 | | - | |
1869 | 1868 | | |
1870 | 1869 | | |
1871 | 1870 | | |
| |||
1880 | 1879 | | |
1881 | 1880 | | |
1882 | 1881 | | |
1883 | | - | |
1884 | | - | |
| 1882 | + | |
| 1883 | + | |
1885 | 1884 | | |
1886 | 1885 | | |
1887 | 1886 | | |
| |||
1896 | 1895 | | |
1897 | 1896 | | |
1898 | 1897 | | |
1899 | | - | |
| 1898 | + | |
1900 | 1899 | | |
1901 | 1900 | | |
1902 | 1901 | | |
| |||
1921 | 1920 | | |
1922 | 1921 | | |
1923 | 1922 | | |
1924 | | - | |
1925 | 1923 | | |
1926 | 1924 | | |
1927 | 1925 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | 125 | | |
127 | 126 | | |
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
131 | 130 | | |
132 | | - | |
133 | 131 | | |
134 | 132 | | |
135 | 133 | | |
| |||
0 commit comments