View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000209 | file | General | public | 2020-11-13 10:44 | 2020-12-16 23:38 |
| Reporter | Helflym | Assigned To | christos | ||
| Priority | normal | Severity | crash | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Product Version | 5.39 | ||||
| Fixed in Version | 5.40 | ||||
| Summary | 0000209: apprentice.c:coalesce_entries can call malloc with a 0 size | ||||
| Description | Hi, When running "regex-eol", it happens that coalesce_entries is called with "nme = 0". Thus, "mentrycount" will be 0 and the malloc for "**ma" will be called with "slen = 0". In most of the OSes, it does work and will return a pointer, but on AIX, it's not allowed and will raise a ENOMEM error. I've made a patch to avoid calling coalesce_entries if there is no entries and it seems to work fine (all tests are OK). It seems the logical approach to me. But I want to be sure that it's the correct way to fix it or if it would be better to still allocate a pointer even when there is no entries, as it's done right now on Linux. Thanks, | ||||
| Tags | No tags attached. | ||||
|
|
file-5.39-avoid-coalesce_entries-when-there-is-no-entries.patch (457 bytes)
--- a/src/apprentice.c 2020-11-13 11:14:12 +0100
+++ b/src/apprentice.c 2020-11-13 11:14:21 +0100
@@ -1461,7 +1461,10 @@
*/
set_last_default(ms, mset[j].me, mset[j].count);
- /* coalesce per file arrays into a single one */
+ /* coalesce per file arrays into a single one, if needed */
+ if (mset[j].count == 0)
+ continue;
+
if (coalesce_entries(ms, mset[j].me, mset[j].count,
&map->magic[j], &map->nmagic[j]) == -1) {
errs++;
|
|
|
Fixed, thanks! |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2020-11-13 10:44 | Helflym | New Issue | |
| 2020-11-13 10:44 | Helflym | File Added: file-5.39-avoid-coalesce_entries-when-there-is-no-entries.patch | |
| 2020-12-16 23:38 | christos | Assigned To | => christos |
| 2020-12-16 23:38 | christos | Status | new => assigned |
| 2020-12-16 23:38 | christos | Status | assigned => resolved |
| 2020-12-16 23:38 | christos | Resolution | open => fixed |
| 2020-12-16 23:38 | christos | Fixed in Version | => 5.40 |
| 2020-12-16 23:38 | christos | Note Added: 0003505 |