Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package minidlna for openSUSE:Factory checked in at 2026-11-16 09:07:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/minidlna (Old) and /work/SRC/openSUSE:Factory/.minidlna.new.1251 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "minidlna" Mon Nov 16 09:07:38 2026 rev:12 rq:1397392 version:1.3.3 Changes: -------- --- /work/SRC/openSUSE:Factory/minidlna/minidlna.changes 2024-08-21 23:28:03.694701004 +0200 +++ /work/SRC/openSUSE:Factory/.minidlna.new.1251/minidlna.changes 2026-11-16 09:12:47.763679826 +0100 @@ -1,0 +2,16 @@ +Fri Nov 13 16:25:04 UTC 2026 - Ruediger Oertel <[email protected]> + +- add some of debian's patches to fix CVE-2026-29508 +- added patches: + - 17-Replace-rm-rf-with-in-process-deletion-code.patch + fix potential quoting issues + - 18-CVE-2026-29508-dff-parser-bounds.patch + fix memory safety issues in dff parser + - 19-upnpevents-unsubscribe-while-connecting.patch + drop notifications if unsubscribed + - 20-select-del-after-fini.patch + fix potential double free + - 22-dsf-parser-bounds.patch + fix memory safety issues in dsf parser + +------------------------------------------------------------------- New: ---- 17-Replace-rm-rf-with-in-process-deletion-code.patch 18-CVE-2026-29508-dff-parser-bounds.patch 19-upnpevents-unsubscribe-while-connecting.patch 20-select-del-after-fini.patch 22-dsf-parser-bounds.patch ----------(New B)---------- New:- added patches: - 17-Replace-rm-rf-with-in-process-deletion-code.patch fix potential quoting issues New: fix potential quoting issues - 18-CVE-2026-29508-dff-parser-bounds.patch fix memory safety issues in dff parser New: fix memory safety issues in dff parser - 19-upnpevents-unsubscribe-while-connecting.patch drop notifications if unsubscribed New: drop notifications if unsubscribed - 20-select-del-after-fini.patch fix potential double free New: fix potential double free - 22-dsf-parser-bounds.patch fix memory safety issues in dsf parser ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ minidlna.spec ++++++ --- /var/tmp/diff_new_pack.RkV4FR/_old 2026-11-16 09:12:49.245741961 +0100 +++ /var/tmp/diff_new_pack.RkV4FR/_new 2026-11-16 09:12:49.247742045 +0100 @@ -1,7 +1,7 @@ # # spec file for package minidlna # -# Copyright (c) 2024 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # Copyright (c) 2012 by Lars Vogdt <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -37,12 +37,18 @@ # VDR FIX thanks to Boris from openSuse Patch1: minidlna-vdr.diff Patch2: 01-run-instead-of-var-run.patch -Patch3: 07-fix-multi-artist-album-handling.patch -Patch4: 08-Fix-testupnpdescgen-build.patch -Patch5: 10-do-not-close-socket-on-sighup.patch -Patch6: 13-spelling-and-typos.patch -Patch7: 15-thumbnails.patch -Patch8: 16-Add-compatibility-with-FFMPEG-7.0.patch +Patch7: 07-fix-multi-artist-album-handling.patch +Patch8: 08-Fix-testupnpdescgen-build.patch +Patch10: 10-do-not-close-socket-on-sighup.patch +Patch13: 13-spelling-and-typos.patch +Patch15: 15-thumbnails.patch +Patch16: 16-Add-compatibility-with-FFMPEG-7.0.patch +Patch17: 17-Replace-rm-rf-with-in-process-deletion-code.patch +Patch18: 18-CVE-2026-29508-dff-parser-bounds.patch +Patch19: 19-upnpevents-unsubscribe-while-connecting.patch +Patch20: 20-select-del-after-fini.patch +Patch22: 22-dsf-parser-bounds.patch + BuildRequires: automake BuildRequires: flac-devel BuildRequires: libexif-devel ++++++ 17-Replace-rm-rf-with-in-process-deletion-code.patch ++++++ From: Simon Tatham <[email protected]> Date: Sun, 15 Sep 2024 20:39:29 +0100 Subject: [PATCH] Replace 'rm -rf' with in-process deletion code. This fixes two edge-case bugs in the code that cleans up minidlna's previous cache directory. Firstly, the 'rm -rf' command wasn't properly quoted, so if a user had configured a more interesting cache directory than the typical /var/cache/minidlna, the rm might have unwanted effects. Secondly, at the time of the call in check_db(), a SIGCHLD handler has been installed which waits for any available process, and also multiple threads are running, meaning that if race conditions work out wrongly, the other thread can reap system()'s subprocess before system() does, causing the wait in glibc's implementation of system() to get ECHILD and system() to report failure. --- minidlna.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/minidlna.c b/minidlna.c index 5c19a34..0c3c762 100644 --- a/minidlna.c +++ b/minidlna.c @@ -338,6 +338,88 @@ open_db(sqlite3 **sq3) return new_db; } +/* Recursive deletion function. 'path' is interpreted relative to the + * fd 'wherefd' (which can be AT_FDCWD to use the cwd, and also, if + * 'path' is an absolute path it doesn't matter what wherefd is). + * + * If the thing you're trying to delete doesn't even exist, that's all + * right. */ +static int +recursive_delete(int wherefd, const char *path) +{ + int fd; + DIR *dir; + struct dirent *de; + + /* First try to delete the given entry using ordinary unlink */ + if (unlinkat(wherefd, path, 0) == 0) + return 0; + /* We just want it gone, so if it's already not there, that's fine */ + if (errno == ENOENT) + return 0; + /* Any error _other_ than EISDIR constitutes failure to delete */ + if (errno != EISDIR) + return -1; + + /* OK, it's a directory. Open it to read filenames from. We + * must do this using openat so that it's relative to wherefd, + * and then we pass that fd to fdopendir to make a convenient + * DIR * out of it. Also this means we still have the fd later + * to use for further unlinkat/openat/etc. */ + fd = openat(wherefd, path, O_RDONLY | O_DIRECTORY); + if (fd < 0) + return -1; + dir = fdopendir(fd); + if (dir == NULL) { + /* Not sure why fdopendir might fail to handle a + * perfectly good directory fd, but let's be careful + * anyway */ + close(fd); + return -1; + } + + /* Now we have a DIR *. Read entries from it and delete them. */ + while ((de = readdir(dir)) != NULL) { + /* Except these two! */ + if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) + continue; + + /* In the recursive call, we pass the bare leaf + * pathname, and give the fd of the containing + * directory as 'wherefd', which saves us (a) + * allocating a fresh pathname, (b) race conditions + * from repeatedly traversing the path from our + * starting location to here. */ + if (recursive_delete(fd, de->d_name) != 0) { + closedir(dir); + return -1; + } + } + closedir(dir); + + /* With any luck, we can now rmdir the directory. */ + if (unlinkat(wherefd, path, AT_REMOVEDIR) == 0) + return 0; + /* Again, if somehow it's already vanished by now, fine by us! */ + if (errno == ENOENT) + return 0; + /* But any other failure is now fatal: we have no more fallbacks. */ + return -1; +} + +static int +clean_cache(void) +{ + char path[PATH_MAX]; + snprintf(path, sizeof(path), "%s/files.db", db_path); + if (recursive_delete(AT_FDCWD, path) != 0) + return -1; + snprintf(path, sizeof(path), "%s/art_cache", db_path); + if (recursive_delete(AT_FDCWD, path) != 0) + return -1; + return 0; +} + static void check_db(sqlite3 *db, int new_db, pid_t *scanner_pid) { @@ -399,8 +481,7 @@ rescan: ret, DB_VERSION); sqlite3_close(db); - snprintf(cmd, sizeof(cmd), "rm -rf %s/files.db %s/art_cache", db_path, db_path); - if (system(cmd) != 0) + if (clean_cache() != 0) DPRINTF(E_FATAL, L_GENERAL, "Failed to clean old file cache! Exiting...\n"); open_db(&db); @@ -939,8 +1020,7 @@ init(int argc, char **argv) SETFLAG(RESCAN_MASK); break; case 'R': - snprintf(buf, sizeof(buf), "rm -rf %s/files.db %s/art_cache", db_path, db_path); - if (system(buf) != 0) + if (clean_cache() != 0) DPRINTF(E_FATAL, L_GENERAL, "Failed to clean old file cache %s. EXITING\n", db_path); break; case 'u': ++++++ 18-CVE-2026-29508-dff-parser-bounds.patch ++++++ Description: Fix memory safety issues in the DFF parser (CVE-2026-29508) _get_dfffileinfo() trusted chunk sizes taken from the file: - the PROP and DIIN chunks were read into variable-length stack arrays of a size taken from the file, without any bound (CVE-2026-29508 for PROP; DIIN has the same problem); - sub-chunks of PROP and DIIN were parsed without checking that they fit in the parent chunk, leading to out-of-bounds reads; - DIAR/DITI sizes below 4 underflowed into huge stack arrays; - a zero DST frame rate caused a division by zero (SIGFPE); - a chunk size that does not fit in off_t made fseeko() seek backwards, so the parser looped forever on the same chunk. Read PROP and DIIN into bounded heap buffers, check every sub-chunk against its parent, guard the divisions and refuse backward seeks. . Also drop the (char *) casts in the FRTE parsing: they caused sign extension and produced bogus durations for DST files. Author: Alexander GQ Gerasiov <[email protected]> Bug-Debian: https://bugs.debian.org/1153446 Forwarded: no Last-Update: 2026-11-08 --- --- a/tagutils/tagutils-dff.c +++ b/tagutils/tagutils-dff.c @@ -36,6 +36,22 @@ #define GET_DFF_INT16(p) ((((uint16_t)((p)[0])) << 8) | \ (((uint16_t)((p)[1])))) +/* Upper bound for the PROP and DIIN chunks, which are read into memory + * as a whole. Real-world chunks are a few hundred bytes. */ +#define DFF_MAX_CHUNK_SIZE (1024 * 1024) + +/* Skip over chunk data. A size that does not fit in off_t would turn + * into a backwards seek and make the parser loop forever. */ +static int +_dff_skip(FILE *fp, uint64_t size) +{ + uint64_t max = sizeof(off_t) == 8 ? (uint64_t)INT64_MAX : (uint64_t)INT32_MAX; + + if (size > max) + return -1; + return fseeko(fp, (off_t)size, SEEK_CUR); +} + static int _get_dfffileinfo(char *file, struct song_metadata *psong) { @@ -60,13 +76,8 @@ unsigned char compressionType[4] = { 0 }; unsigned char dsdsdckData[12] = { 0 }; uint64_t dsdsdckDataSize = 0; - uint64_t cmprckDataSize = 0; - uint64_t abssckDataSize = 0; - uint64_t lscockDataSize = 0; uint64_t comtckDataSize = 0; uint64_t diinckDataSize = 0; - uint64_t diarckDataSize = 0; - uint64_t ditickDataSize = 0; uint64_t manfckDataSize = 0; //DPRINTF(E_DEBUG,L_SCANNER,"Getting DFF fileinfo =%s\n",file); @@ -124,14 +135,28 @@ //Property chunk if (strncmp((char*)ckbuf, "PROP", 4) == 0) { + unsigned char *propckData; + propckDataSize = GET_DFF_INT64(ckbuf + 4); + if (propckDataSize < 4 || propckDataSize > DFF_MAX_CHUNK_SIZE) + { + DPRINTF(E_WARN, L_SCANNER, "Invalid Property chunk size in %s\n", file); + fclose(fp); + return -1; + } totalcount += propckDataSize + 12; - unsigned char propckData[propckDataSize]; + propckData = malloc(propckDataSize); + if (!propckData) + { + fclose(fp); + return -1; + } if (!(rt = fread(propckData, propckDataSize, 1, fp))) { DPRINTF(E_WARN, L_SCANNER, "Could not read Property chunk from %s\n", file); + free(propckData); fclose(fp); return -1; } @@ -139,61 +164,64 @@ if (strncmp((char*)propckData, "SND ", 4)) { DPRINTF(E_WARN, L_SCANNER, "Invalid Property chunk in %s\n", file); + free(propckData); fclose(fp); return -1; } - count += 4; - while (count < propckDataSize) + /* Each sub-chunk is: 4-byte ID, 8-byte size, data. + * Make sure the header and the data fit in the chunk. */ + count = 4; + while (count + 12 <= propckDataSize) { + uint64_t subsize = GET_DFF_INT64(propckData + count + 4); + unsigned char *subdata = propckData + count + 12; + + if (subsize > propckDataSize - count - 12) + break; + if (strncmp((char*)propckData + count, "FS ", 4) == 0) { //Sample Rate Chunk - count += 12; - samplerate = GET_DFF_INT32(propckData + count); + if (subsize < 4) + break; + samplerate = GET_DFF_INT32(subdata); psong->samplerate = samplerate; - count += 4; //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Sample Rate is %d\n", psong->samplerate); } else if (strncmp((char*)propckData + count, "CHNL", 4) == 0) { //Channels Chunk - count += 12; - channels = GET_DFF_INT16(propckData + count); + if (subsize < 2) + break; + channels = GET_DFF_INT16(subdata); psong->channels = channels; - count += channels * 4 + 2; //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "channels is %d\n", channels); } else if (strncmp((char*)propckData + count, "CMPR", 4) == 0) { //Compression Type Chunk - count += 4; - cmprckDataSize = GET_DFF_INT64(propckData + count); - count += 8; - memcpy(compressionType, propckData + count, 4); - count += cmprckDataSize; + if (subsize < 4) + break; + memcpy(compressionType, subdata, 4); } else if (strncmp((char*)propckData + count, "ABSS", 4) == 0) { //Absolute Start Time Chunk - count += 4; - abssckDataSize = GET_DFF_INT64(propckData + count); - count += abssckDataSize + 8; } else if (strncmp((char*)propckData + count, "LSCO", 4) == 0) { //Loudsperaker Configuration Chunk - count += 4; - lscockDataSize = GET_DFF_INT64(propckData + count); - count += lscockDataSize + 8; } else { break; } + count += 12 + subsize; } + free(propckData); //bitrate bitpersample is 1bit psong->bitrate = channels * samplerate * 1; @@ -219,11 +247,13 @@ //DSD dsdsdckDataSize = GET_DFF_INT64(dsdsdckData + 4); totalcount += dsdsdckDataSize + 12; - psong->song_length = (int)((double)dsdsdckDataSize / (double)samplerate / (double)channels * 8 * 1000); + if (samplerate && channels) + psong->song_length = (int)((double)dsdsdckDataSize / (double)samplerate / (double)channels * 8 * 1000); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "songlength is %d\n", psong->song_length); - fseeko(fp, dsdsdckDataSize, SEEK_CUR); + if (_dff_skip(fp, dsdsdckDataSize)) + break; } else if (strncmp((char*)dsdsdckData, "DST ", 4) == 0) { @@ -242,12 +272,14 @@ if (strncmp((char*)frteckData, "FRTE", 4) == 0) { //uint64_t frteckDataSize = GET_DFF_INT64(frteckData+4); - numFrames = GET_DFF_INT32((char*)frteckData + 12); - frameRate = GET_DFF_INT16((char*)frteckData + 16); + numFrames = GET_DFF_INT32(frteckData + 12); + frameRate = GET_DFF_INT16(frteckData + 16); - psong->song_length = numFrames / frameRate * 1000; + if (frameRate) + psong->song_length = numFrames / frameRate * 1000; - fseeko(fp, dsdsdckDataSize - 18, SEEK_CUR); + if (dsdsdckDataSize < 18 || _dff_skip(fp, dsdsdckDataSize - 18)) + break; } else { @@ -276,7 +308,8 @@ { dstickDataSize = GET_DFF_INT64(dstickData + 4); totalcount += dstickDataSize + 12; - fseeko(fp, dstickDataSize, SEEK_CUR); + if (_dff_skip(fp, dstickDataSize)) + break; } else { @@ -295,78 +328,90 @@ //COMT Chunk comtckDataSize = GET_DFF_INT64(ckbuf + 4); totalcount += comtckDataSize + 12; - fseeko(fp, comtckDataSize, SEEK_CUR); + if (_dff_skip(fp, comtckDataSize)) + break; } else if (!strncmp((char*)ckbuf, "DIIN", 4)) { //Edited Master Information chunk + unsigned char *diinckData; + diinckDataSize = GET_DFF_INT64(ckbuf + 4); - unsigned char diinckData[diinckDataSize]; totalcount += diinckDataSize + 12; + if (diinckDataSize == 0 || diinckDataSize > DFF_MAX_CHUNK_SIZE) + { + /* Optional metadata: skip it, keep the audio info */ + DPRINTF(E_WARN, L_SCANNER, "Skipping Edited Master Information chunk of invalid size in %s\n", file); + if (_dff_skip(fp, diinckDataSize)) + break; + continue; + } + + diinckData = malloc(diinckDataSize); + if (!diinckData) + { + fclose(fp); + return -1; + } if (!(rt = fread(diinckData, diinckDataSize, 1, fp))) { DPRINTF(E_WARN, L_SCANNER, "Could not read Edited Master Information chunk from %s\n", file); + free(diinckData); fclose(fp); return -1; } + /* Each sub-chunk is: 4-byte ID, 8-byte size, data. + * Make sure the header and the data fit in the chunk. */ uint64_t icount = 0; - while (icount < diinckDataSize) + while (icount + 12 <= diinckDataSize) { + uint64_t subsize = GET_DFF_INT64(diinckData + icount + 4); + unsigned char *subdata = diinckData + icount + 12; + + if (subsize > diinckDataSize - icount - 12) + break; + if (!strncmp((char*)diinckData + icount, "EMID", 4)) { //Edited Master ID chunk - icount += 4; - icount += GET_DFF_INT64(diinckData + icount) + 8; } else if (!strncmp((char*)diinckData + icount, "MARK", 4)) { //Master Chunk - icount += 4; - icount += GET_DFF_INT64(diinckData + icount) + 8; } else if (!strncmp((char*)diinckData + icount, "DIAR", 4)) { - //Artist Chunk - icount += 4; - diarckDataSize = GET_DFF_INT64(diinckData + icount); - unsigned char arttext[diarckDataSize + 1 - 4]; - - icount += 12; - - memset(arttext, 0x00, sizeof(arttext)); - strncpy((char*)arttext, (char*)diinckData + icount, sizeof(arttext) - 1); - psong->contributor[ROLE_ARTIST] = strdup((char*)&arttext[0]); - - icount += diarckDataSize - 4; + //Artist Chunk: 4-byte text length, then the text + if (subsize < 4) + break; + if (!psong->contributor[ROLE_ARTIST]) + psong->contributor[ROLE_ARTIST] = strndup((char*)subdata + 4, subsize - 4); } else if (!strncmp((char*)diinckData + icount, "DITI", 4)) { - //Title Chunk - icount += 4; - ditickDataSize = GET_DFF_INT64(diinckData + icount); - unsigned char titletext[ditickDataSize + 1 - 4]; - - icount += 12; - - memset(titletext, 0x00, sizeof(titletext)); - strncpy((char*)titletext, (char*)diinckData + icount, sizeof(titletext) - 1); - psong->title = strdup((char*)&titletext[0]); - icount += ditickDataSize - 4; + //Title Chunk: 4-byte text length, then the text + if (subsize < 4) + break; + if (!psong->title) + psong->title = strndup((char*)subdata + 4, subsize - 4); } else { break; } + icount += 12 + subsize; } + free(diinckData); } else if (!strncmp((char*)ckbuf, "MANF", 4)) { //Manufacturer Specific Chunk manfckDataSize = GET_DFF_INT64(ckbuf + 4); totalcount += manfckDataSize + 12; - fseeko(fp, manfckDataSize, SEEK_CUR); + if (_dff_skip(fp, manfckDataSize)) + break; } } @@ -374,15 +419,10 @@ //DPRINTF(E_DEBUG, L_SCANNER, "totalsize is 0x%016lx\n", (long unsigned int)totalsize); //DPRINTF(E_DEBUG, L_SCANNER, "propckDataSize is 0x%016lx\n", (long unsigned int)propckDataSize); - //DPRINTF(E_DEBUG, L_SCANNER, "cmprckDataSize is 0x%016lx\n", (long unsigned int)cmprckDataSize); - //DPRINTF(E_DEBUG, L_SCANNER, "abssckDataSize is 0x%016lx\n", (long unsigned int)abssckDataSize); - //DPRINTF(E_DEBUG, L_SCANNER, "lscockDataSize is 0x%016lx\n", (long unsigned int)lscockDataSize); //DPRINTF(E_DEBUG, L_SCANNER, "dsdsdckDataSize is 0x%016lx\n", (long unsigned int)dsdsdckDataSize); //DPRINTF(E_DEBUG, L_SCANNER, "dstickDataSize is 0x%016lx\n", (long unsigned int)dstickDataSize); //DPRINTF(E_DEBUG, L_SCANNER, "comtckDataSize is 0x%016lx\n", (long unsigned int)comtckDataSize); //DPRINTF(E_DEBUG, L_SCANNER, "diinckDataSize is 0x%016lx\n", (long unsigned int)diinckDataSize); - //DPRINTF(E_DEBUG, L_SCANNER, "diarckDataSize is 0x%016lx\n", (long unsigned int)diarckDataSize); - //DPRINTF(E_DEBUG, L_SCANNER, "ditickDataSize is 0x%016lx\n", (long unsigned int)ditickDataSize); //DPRINTF(E_DEBUG, L_SCANNER, "manfckDataSize is 0x%016lx\n", (long unsigned int)manfckDataSize); ++++++ 19-upnpevents-unsubscribe-while-connecting.patch ++++++ Description: Do not abort when a subscriber goes away while connecting If a client unsubscribes while the initial event notification is still connecting to its callback URL, upnpevents_removeSubscriber() clears notify->sub, and upnp_event_prepare() then hits assert(obj->sub) and aborts the whole daemon. Any host on the LAN can trigger this with a SUBSCRIBE to an unresponsive callback followed by an UNSUBSCRIBE. Drop such notifications instead. Author: Alexander GQ Gerasiov <[email protected]> Bug-Debian: https://bugs.debian.org/1144655 Forwarded: no Last-Update: 2026-11-08 --- diff --git a/upnpevents.c b/upnpevents.c index 1e44ffe..23033a0 100644 --- a/upnpevents.c +++ b/upnpevents.c @@ -408,6 +408,14 @@ upnp_event_process_notify(struct event *ev) switch(obj->state) { case EConnecting: /* now connected or failed to connect */ + if (!obj->sub) { + /* The subscriber was removed (UNSUBSCRIBE) while + * we were connecting: drop the notification. */ + DPRINTF(E_DEBUG, L_HTTP, "upnp_event_process_notify: subscriber gone, dropping notify\n"); + obj->state = EFinished; + event_module.del(&obj->ev, EV_FLAG_CLOSING); + break; + } upnp_event_prepare(obj); upnp_event_send(obj); break; ++++++ 20-select-del-after-fini.patch ++++++ Description: Make select_del() safe after select_fini() and on double delete A child forked by process_fork() calls event_module.fini(), which frees the events table but leaves nevents untouched. When the child later closes its HTTP socket, select_del() dereferences the freed (NULL) table and the child crashes with SIGSEGV whenever the connection is not the last registered event. A second select_del() on the same event would also write to events[-1]. Reset nevents in select_fini() and make select_del() a no-op for events that are not registered. Author: Alexander GQ Gerasiov <[email protected]> Bug-Debian: https://bugs.debian.org/989828 Bug-Debian: https://bugs.debian.org/1138586 Forwarded: no Last-Update: 2026-11-08 --- diff --git a/select.c b/select.c index e287760..70e9820 100644 --- a/select.c +++ b/select.c @@ -83,6 +83,7 @@ select_fini(void) free(events); events = NULL; + nevents = 0; } static int @@ -115,6 +116,16 @@ static int select_del(struct event *ev, int flags) { + /* + * Nothing to do if the event is not registered: it was already + * deleted, or select_fini() has been called, which happens in a + * child forked by process_fork() before it closes its sockets. + */ + if (events == NULL || ev->index < 0) { + ev->index = -1; + return (0); + } + assert(ev->fd < FD_SETSIZE); switch (ev->rdwr) { ++++++ 22-dsf-parser-bounds.patch ++++++ Description: Fix memory safety issues in the DSF parser The DSF reader, like the DFF one (CVE-2026-29508), trusted values taken from the file: - the sampling frequency was used as a divisor without checking it for zero (SIGFPE); - the metadata chunk was malloc()ed and memset() with a size computed from the header, with no upper bound, so a crafted header could make the scanner allocate and touch gigabytes of memory; - GET_DSF_INT32 shifted uint8_t values promoted to int by 24 bits, which is undefined behaviour for bytes >= 0x80. Bound the metadata chunk by the real file size and by 64 MiB, guard the division, do the shifts on uint32_t and check the cover art malloc(). Author: Alexander GQ Gerasiov <[email protected]> Forwarded: no Last-Update: 2026-11-08 --- --- a/tagutils/tagutils-dsf.c +++ b/tagutils/tagutils-dsf.c @@ -30,10 +30,14 @@ (((uint64_t)((p)[1])) << 8) | \ (((uint64_t)((p)[0])))) -#define GET_DSF_INT32(p) ((((uint8_t)((p)[3])) << 24) | \ - (((uint8_t)((p)[2])) << 16) | \ - (((uint8_t)((p)[1])) << 8) | \ - (((uint8_t)((p)[0])))) +#define GET_DSF_INT32(p) ((((uint32_t)((p)[3])) << 24) | \ + (((uint32_t)((p)[2])) << 16) | \ + (((uint32_t)((p)[1])) << 8) | \ + (((uint32_t)((p)[0])))) + +/* Upper bound for the ID3 metadata chunk, which is read into memory as a + * whole. Large enough for tags with embedded cover art. */ +#define DSF_MAX_METADATA_SIZE (64 * 1024 * 1024) static int _get_dsftags(char *file, struct song_metadata *psong) @@ -61,6 +65,7 @@ uint64_t pointer_to_metadata_chunk = 0; uint64_t metadata_chunk_size = 0; unsigned char *id3tagbuf = NULL; + struct stat st; //DEBUG DPRINTF(E_DEBUG,L_SCANNER,"Getting DSF file info\n"); @@ -118,6 +123,23 @@ return 0; } + /* The sizes come from the file: do not trust them beyond the real + * file size, and do not read huge chunks into memory. */ + if (fstat(fileno(fp), &st) != 0 || (uint64_t)st.st_size <= pointer_to_metadata_chunk) + { + fclose(fp); + DPRINTF(E_INFO, L_SCANNER, "Invalid PointerToMetadata in %s\n", file); + return 0; + } + if (metadata_chunk_size > (uint64_t)st.st_size - pointer_to_metadata_chunk) + metadata_chunk_size = (uint64_t)st.st_size - pointer_to_metadata_chunk; + if (metadata_chunk_size > DSF_MAX_METADATA_SIZE) + { + fclose(fp); + DPRINTF(E_WARN, L_SCANNER, "Metadata chunk too big in %s\n", file); + return 0; + } + fseeko(fp, pointer_to_metadata_chunk, SEEK_SET); id3tagbuf = (unsigned char*)malloc(sizeof(unsigned char) * metadata_chunk_size); @@ -186,8 +208,11 @@ if (image_size) { psong->image = malloc(image_size); - memcpy(psong->image, image, image_size); - psong->image_size = image_size; + if (psong->image) + { + memcpy(psong->image, image, image_size); + psong->image_size = image_size; + } //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Found thumbnail: %d\n", psong->image_size); } } @@ -410,7 +435,8 @@ psong->bitrate = channelnum * samplingfrequency * bitpersample; psong->samplesize = bitpersample; psong->samplerate = samplingfrequency; - psong->song_length = (samplecount / samplingfrequency) * 1000; + if (samplingfrequency) + psong->song_length = (samplecount / samplingfrequency) * 1000; psong->channels = channelnum; DPRINTF(E_MAXDEBUG, L_SCANNER, "Got file info successfully for %s\n", file);
