⬢ DragonFlyBSD Kernel Audit
DF-2249 / fix.diff
← back to finding ↓ download raw
--- a/sys/libiconv/iconv_xlat.c
+++ b/sys/libiconv/iconv_xlat.c
@@ -89,10 +89,14 @@
 		return 0;
 	if (casetype != 0)
 		return -1;
-	if (convchar == 1)
+	if (convchar == 1) {
+		if (*inbytesleft == 0 || *outbytesleft == 0) {
+			/* no input byte / no output byte available */
+			return (-1);
+		}
 		r = n = 1;
-	else
-		r = n = min(*inbytesleft, *outbytesleft);
+	} else
+		r = n = szmin(*inbytesleft, *outbytesleft);
 	src = *inbuf;
 	dst = *outbuf;
 	while(r--)