"Drive-by-download" refers to the behaviour of the malware: it will (attempt to) infect the user during normal interaction with a web page.
Buffer and stack overflow, on the other hand, are two technics used to attack a vulnerable application. They are not limited to the web in any way. (any software that takes some form of input - i.e. all software - is potentially vulnerable).
So a malware might spread through drive-by-download by leveraging a stack overflow in a vulnerable component.
A drive-by-download isn't an attack. It just means that the malware will be automatically downloaded and executed without the user doing anything (I.E. You only have to visit a site for you to be infected). It may well be delivered via a JS exploit.
This differentiates it from user-initiated malware, where a website will trick you into downloading and running something (say, a fake antivirus).
(1) Drive-By-Download Attack
A 'drive-by-download' attack is a malware delivery technique that is triggered simply because the user visited a website. A drive-by download Malware will usually take advantage of (or “exploit”) a browser, app, or operating system that is out of date and has a security flaw.
You might receive a link in an email, text message, or social media post that tells you to look at something interesting on a site. When you open the page, while you are enjoying the article or cartoon, the download is installing on your computer.
(2) Stack Buffer Overflow Attack
The Stack Buffer Overflow attack results from input that is longer than the implement or intended.
There are three common varieties of buffer overflow attacks: stack attacks, format string attacks, and heap attacks . Each attack is similar but affects a different part of a computer's memory .
(a) Stack Attacks
The perpetrator adds more data than expected to the stack, overwriting data that the programmer thought would never be in any danger of being replaced.
(b) Format String Attacks
Involves a much smaller change than the stack buffer overflow .Format string attacks usually add a single address in memory that points to another address in memory where the attacker has added new instructions to execute
(c) Heap Attacks
The heap attack does not involve the stack at all .Pages in the heap can be read from and written to, and attackers take advantage of this by writing attack instructions into the pages in the heap, then tricking the computer into following these instructions .