Valhalla Legends Archive

Programming => General Programming => Topic started by: brew on September 13, 2007, 08:04 PM

Title: Rich Edit control's EM_GETSELTEXT
Post by: brew on September 13, 2007, 08:04 PM
http://msdn2.microsoft.com/en-us/library/bb774190.aspx
Am I crazy, or should wParam be the max buffer length for the char array that you supply the pointer to in the lParam? This message is very poorly designed. What were they thinking, having the wParam not used? This can easily be exploited by just over-selecting text, and the amount of text in a rich edit box could get quite lengthy. To be completely honest, I'm scared to even try it. Somehow I really doubt that Microsoft would make their rich edit message handlers this insecure, so is there a better way to determine how big your buffer should be? Besides using EM_GETTEXTLENGTHEX?
Title: Re: Rich Edit control's EM_GETSELTEXT
Post by: Barabajagal on September 13, 2007, 09:38 PM
How can you over-select text? GetSelText gets the selection, it doesn't set it.
Title: Re: Rich Edit control's EM_GETSELTEXT
Post by: Zorm on September 13, 2007, 10:20 PM
EM_EXGETSEL
Title: Re: Rich Edit control's EM_GETSELTEXT
Post by: brew on September 14, 2007, 02:08 PM
Quote from: Andy on September 13, 2007, 09:38 PM
How can you over-select text? GetSelText gets the selection, it doesn't set it.
Say your buffer is 1024 bytes. You select 1536 characters. Those characters happen to be binary data. You fail, buffer overflow. I was asking if there was a way to determine how big your buffer should be before you use EM_GETSELTEXT.
By the way, thank you Zorm.