Commit 9121093
committed
config: remove unneeded path field
As well as passing the key value pair, the config machinery also passes
a "struct key_value_info" containing information about the source of
that pair to the config parsing callback. 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 pair 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 "filename"
but the "path" field is not actually needed. It is a copy of the same
field from "struct config_source". That field was added in d14d424
(config: disallow relative include paths from blobs, 2014-02-19)
to distinguish relative include directives in files from 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 config origin. So let's remove the "path" members from
"struct config_source" and "struct key_value_info" and instead use a
combination of "filename" and "origin_type" to determine the absolute
path of relative includes.
Signed-off-by: Phillip Wood <[email protected]>1 parent a30f80f commit 9121093
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 | | |
| |||
1850 | 1847 | | |
1851 | 1848 | | |
1852 | 1849 | | |
1853 | | - | |
1854 | | - | |
| 1850 | + | |
| 1851 | + | |
1855 | 1852 | | |
1856 | 1853 | | |
1857 | 1854 | | |
1858 | 1855 | | |
1859 | 1856 | | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
1860 | 1860 | | |
1861 | 1861 | | |
1862 | 1862 | | |
1863 | | - | |
1864 | 1863 | | |
1865 | 1864 | | |
1866 | 1865 | | |
| |||
1875 | 1874 | | |
1876 | 1875 | | |
1877 | 1876 | | |
1878 | | - | |
1879 | | - | |
| 1877 | + | |
| 1878 | + | |
1880 | 1879 | | |
1881 | 1880 | | |
1882 | 1881 | | |
| |||
1891 | 1890 | | |
1892 | 1891 | | |
1893 | 1892 | | |
1894 | | - | |
| 1893 | + | |
1895 | 1894 | | |
1896 | 1895 | | |
1897 | 1896 | | |
| |||
1916 | 1915 | | |
1917 | 1916 | | |
1918 | 1917 | | |
1919 | | - | |
1920 | 1918 | | |
1921 | 1919 | | |
1922 | 1920 | | |
| |||
| 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