Re: [Asterisk-java-users] fastagi.command.GetDataCommand issue
Brought to you by:
srt
From: Steve D. <Ste...@Su...> - 2005-05-03 23:44:02
|
On Apr 29, 2005, at 4:56 PM, Stefan Reuter wrote: >>> It seems to me that "GET DATA foo" is translated to "GET DATA foo 0 >>> 1024" and thats exactly what asterisk-java sends. right? >>> >> >> Yes, that is what it sends. I think it should send "GET DATA foo". >> > > hmm we could do this, though it would imply to use nullable Integers > instead of the easier to use ints for timeout and maxDigits. Um, just change return "GET DATA " + escapeAndQuote(file) + " " + timeout + ... to "GET DATA " + escapeAndQuote(file) + " " + (timeout != 0 ? timeout : "") and likewise for maxDigits. > That would > make GetDataCommand quite different from the other Commands that use > primitive attributes. "Consistency is the hobgoblin of small minds" ;-) > Nevertheless asterisk uses a default timeout of 0 and a default > maxDigits of 1024, so there is really no semantic difference > between the > two. In fact there is. If you send "GET FILE foo", then ast_readstring_full gets timeout=2000 and ftimeout=6000. But if you send "GET FILE foo 0 1024, then timeout=ftimeout=6000. > You might consider this knowledge of asterisk internals a violation > of encapsulation practices but some knowledge is needed anyway > (i.e. to > enforce the maximum maxDigits of 1024 to prevent buffer overflows, see > below). Not at all. Asterisk enforces the max length of 1024 as it should, since it owns the buffer. Asterisk-java has no business knowing this. Nor should it care as long as it sends the syntactically correct GET DATA command, which is documented in res_agi.c as: GET DATA <file to be streamed> [timeout] [max digits] Which actually is wrong. It should be: GET DATA <file to be streamed> [timeout [max digits]] > Using 1024 as maxDigits is the maximum number of digits GET DATA can > handle anyway as the buffer that is used by asterisk is defined as > char data[1024]. Although asterisk does not enforce a maximum of 1024 > reading more digits would result in a buffer overflow. Actually, Asterisk does enforce the 1024 limit. |