git: d80a1943a8dd - main - sysutils/cdrdao: Fix zero length DMA with ata(4)

From: Jason E. Hale <jhale_at_FreeBSD.org>
Date: Wed, 15 May 2024 22:12:48 UTC
The branch main has been updated by jhale:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d80a1943a8ddb184de2a4e78ba3efc0eafb5e133

commit d80a1943a8ddb184de2a4e78ba3efc0eafb5e133
Author:     Jason E. Hale <jhale@FreeBSD.org>
AuthorDate: 2024-05-15 21:58:18 +0000
Commit:     Jason E. Hale <jhale@FreeBSD.org>
CommitDate: 2024-05-15 22:12:30 +0000

    sysutils/cdrdao: Fix zero length DMA with ata(4)
    
    Fix zero length DMA transfer attempted failures with the ata(4) driver.
    This does not seem to affect users of the ahci(4) driver.
    
    While here, convert bzero/bcopy to memset/memmove, respectively.
    
    PR:             277115
    Reported by:    Benjamin Jacobs <freebsd@dev.thsi.be>
---
 sysutils/cdrdao/Makefile                           |  2 +-
 .../cdrdao/files/patch-dao_ScsiIf-freebsd-cam.cc   | 29 ++++++++++++++++++++++
 sysutils/cdrdao/files/patch-trackdb_FormatMp3.cc   | 11 ++++++++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/sysutils/cdrdao/Makefile b/sysutils/cdrdao/Makefile
index 9bcc5a62a116..b968d34fd8a1 100644
--- a/sysutils/cdrdao/Makefile
+++ b/sysutils/cdrdao/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	cdrdao
 DISTVERSION=	1_2_5
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils audio
 MASTER_SITES=	https://github.com/${PORTNAME}/${PORTNAME}/releases/download/rel_${DISTVERSION}/ \
 		SF/${PORTNAME}/rel_${DISTVERSION}
diff --git a/sysutils/cdrdao/files/patch-dao_ScsiIf-freebsd-cam.cc b/sysutils/cdrdao/files/patch-dao_ScsiIf-freebsd-cam.cc
new file mode 100644
index 000000000000..6b39efbe9ab9
--- /dev/null
+++ b/sysutils/cdrdao/files/patch-dao_ScsiIf-freebsd-cam.cc
@@ -0,0 +1,29 @@
+--- dao/ScsiIf-freebsd-cam.cc.orig	2023-01-25 14:30:35 UTC
++++ dao/ScsiIf-freebsd-cam.cc
+@@ -112,11 +112,11 @@ int ScsiIf::sendCmd(const unsigned char *cmd, int cmdL
+ {
+ 	int		retval;
+ 	int		flags = CAM_DIR_NONE;
+-	u_int8_t *	data_ptr;
+-	size_t		data_len;
++	u_int8_t *	data_ptr = NULL;
++	size_t		data_len = 0;
+ 
+-	bzero(impl_->ccb, sizeof(union ccb));
+-	bcopy(cmd, &impl_->ccb->csio.cdb_io.cdb_bytes, cmdLen);
++	memset(impl_->ccb, 0, sizeof(union ccb));
++	memmove(&impl_->ccb->csio.cdb_io.cdb_bytes, cmd, cmdLen);
+ 
+ 	if (dataOut && dataOutLen > 0) {
+ 		data_ptr = (u_int8_t*) dataOut;
+@@ -176,8 +176,8 @@ int ScsiIf::inquiry()
+ 	int i;
+ 	struct scsi_inquiry_data inq_data;
+ 
+-	bzero(impl_->ccb, sizeof(union ccb));
+-	bzero(&inq_data, sizeof(inq_data));
++	memset(impl_->ccb, 0, sizeof(union ccb));
++	memset(&inq_data, 0, sizeof(inq_data));
+ 
+ 	scsi_inquiry(&impl_->ccb->csio,
+ 		     DEF_RETRY_COUNT,
diff --git a/sysutils/cdrdao/files/patch-trackdb_FormatMp3.cc b/sysutils/cdrdao/files/patch-trackdb_FormatMp3.cc
new file mode 100644
index 000000000000..7b8da328df14
--- /dev/null
+++ b/sysutils/cdrdao/files/patch-trackdb_FormatMp3.cc
@@ -0,0 +1,11 @@
+--- trackdb/FormatMp3.cc.orig	2023-02-03 14:46:06 UTC
++++ trackdb/FormatMp3.cc
+@@ -111,7 +111,7 @@ FormatSupport::Status FormatMp3::madInit()
+ 
+   // Initialize libao for WAV output;
+   ao_sample_format out_format;
+-  bzero(&out_format, sizeof(out_format));
++  memset(&out_format, 0, sizeof(out_format));
+   out_format.bits = 16;
+   out_format.rate = 44100;
+   out_format.channels = 2;