Date: Sun, 19 Feb 2023 17:14:00 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 269688] memalign() produces division by zero if size is 0 Message-ID: <bug-269688-227-wES4s9fiRI@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-269688-227@https.bugs.freebsd.org/bugzilla/> References: <bug-269688-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D269688 --- Comment #2 from Paul Floyd <pjfloyd@wanadoo.fr> --- On other platforms the behaviour is: macOS doesn't exist Linux glibc just calls malloc https://elixir.bootlin.com/glibc/glibc-2.37.9000/source/malloc/malloc.c#L35= 10 /* If we need less alignment than we give anyway, just relay to malloc. = */ if (alignment <=3D MALLOC_ALIGNMENT) return __libc_malloc (bytes); musl just calls malloc https://github.com/esmil/musl/blob/master/src/malloc/memalign.c if (align <=3D 4*sizeof(size_t)) { if (!(mem =3D malloc(len))) return NULL; return mem; } illimos sets EINVAL and returns NULL https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/g= en/memalign.c /* * check for valid size and alignment parameters * MAX_ALIGN check prevents overflow in later calculation. */ if (nbytes =3D=3D 0 || _misaligned(align) || align =3D=3D 0 || align > MAX_ALIGN) { errno =3D EINVAL; return (NULL); } --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-269688-227-wES4s9fiRI>