Commit 96ec45a
committed
samples/tasks: repair database demo, add decompress test
Two related changes under samples/tasks/.
samples/tasks/database: restore a buildable state
The database demo had bit-rotted to the point where neither the
C source nor the Makefile matched the current tree:
* main_msg_queue_push: retro_task_queue_msg_t gained a
retro_task_t* first parameter
* main_db_cb: retro_task_callback_t gained the same
* core_info_init_list: added a sixth bool *cache_supported
parameter
* Makefile: hash/rhash.c was renamed to hash/lrc_hash.c
* Makefile: 7zip source list was stale -- 7zIn.c was renamed to
7zArcIn.c, and BraIA64.c / CpuArch.c / Delta.c were added
* Makefile: missing sources for trans_stream*, rzip_stream,
features_cpu, rtime, rxml, m3u_file, logiqx_dat,
manual_content_scan, yxml
* link: missing -lm for roundf
Several symbols reached via task_push_dbscan are defined only
when RARCH_INTERNAL is set, which would transitively require
linking most of retroarch.c, frontend_driver.c, runloop.c,
configuration.c and the UI/video subsystems. Since this sample
exercises only the task queue, it provides lightweight stubs for:
* msg_hash_get_help_us_enum (real def in intl/msg_hash_us.c)
* msg_hash_to_str_us (real def in intl/msg_hash_us.c)
* config_get_ptr (real def in configuration.c)
* runloop_msg_queue_push (real def in runloop.c)
* retroarch_override_setting_is_set
* ui_companion_driver_notify_refresh
* video_display_server_set_window_progress
* frontend_driver_get_free_memory
* dir_list_new_special (real def in retroarch.c)
All stubs are either no-ops or return a conservative value that
lets the surrounding code bail gracefully; none of them are
exercised on the happy dbscan path.
After these changes the demo builds cleanly on a stock Ubuntu
host (build-essential, zlib1g-dev, libpthread), and both
`database_task` with no args and `database_task <5 dirs>` exit
with the expected status.
samples/tasks/decompress: new standalone regression test
Adds archive_name_safety_test, a 23-case predicate unit test for
the archive_name_is_safe() function in tasks/task_decompress.c.
This test was originally developed alongside the Zip Slip patch
in the first security round and held out of
libretro-common/samples/ because it exercises code in tasks/
rather than libretro-common/. samples/tasks/ is its natural
home.
The test keeps a verbatim copy of the predicate and validates it
against a table of safe / unsafe paths:
* safe: file.txt, dir/file.txt, a.b/c, ..foo, foo..
* unsafe: .., ../etc/passwd, foo/..//bar, /etc/passwd,
\windows\system32, C:\evil, c:/evil, ..\..\windows,
foo\..\bar, empty string, NULL
If the predicate in task_decompress.c is ever edited, the copy
here must be updated to match -- this is noted in the test file's
header.1 parent b569dd0 commit 96ec45a
4 files changed
Lines changed: 278 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | 98 | | |
| 99 | + | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| |||
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | | - | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| 119 | + | |
117 | 120 | | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
126 | 134 | | |
| 135 | + | |
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
| |||
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
| 146 | + | |
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
| |||
142 | 152 | | |
143 | 153 | | |
144 | 154 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
152 | 158 | | |
153 | | - | |
154 | 159 | | |
| 160 | + | |
| 161 | + | |
155 | 162 | | |
156 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
157 | 169 | | |
158 | | - | |
| 170 | + | |
| 171 | + | |
159 | 172 | | |
160 | 173 | | |
161 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
13 | 93 | | |
14 | 94 | | |
15 | 95 | | |
| 96 | + | |
16 | 97 | | |
17 | 98 | | |
18 | 99 | | |
| |||
23 | 104 | | |
24 | 105 | | |
25 | 106 | | |
26 | | - | |
| 107 | + | |
| 108 | + | |
27 | 109 | | |
| 110 | + | |
28 | 111 | | |
29 | 112 | | |
30 | 113 | | |
| |||
66 | 149 | | |
67 | 150 | | |
68 | 151 | | |
69 | | - | |
| 152 | + | |
70 | 153 | | |
71 | 154 | | |
72 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
0 commit comments