Re: WARNING: SMPP: PDU element <password> to long (length is 9, should be 9)

Alexander Malysh <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi,

Stipe Tolj wrote:

> Aarno SyvÀnen wrote:
> 
>> The entity is NULTERMINATED, octet string is not. So \0 is added, in
>> the last line,
>> and that's why the comparison is >=. And of course, max-octets does not
>> include
>> terminating \0.

NULTERMINATED as Aarno pointed already, is C string with terminating \0.
max-octets is _including_ terminating \0. comparison > is no enough,
because if octstr len even equal to max-octets than that means we will drop
1 octet (because \0 will be added at the end), so the warninng and
comparison is correct. But in order to not confuse users we could do
something like this:
...
     #define NULTERMINATED(name, max_octets) \
         if (p->name != NULL) { \
             if (octstr_len(p->name) >= max_octets) { \
                 warning(0, "SMPP: PDU element <%s> to long " \
                         "(length is %ld, should be %d)", \
                         #name, octstr_len(p->name), max_octets - 1); \
                                                     ^^^^^^^^^^^^^^
                 temp = octstr_copy(p->name, 0, max_octets-1); \
             } else \
                 temp = octstr_duplicate(p->name); \
             octstr_append(os, temp); \
             octstr_destroy(temp); \
         } \
         octstr_append_char(os, '\0');
...


> 
> ok, but is the equal comparison realy required? wouldn't > be enough?
> 
> Stipe
> 
> mailto:stolj_{at}_wapme.de
> -------------------------------------------------------------------
> Wapme Systems AG
> 
> Vogelsanger Weg 80
> 40470 DÃŒsseldorf, NRW, Germany
> 
> phone: +49.211.74845.0
> fax: +49.211.74845.299
> 
> mailto:info_{at}_wapme-systems.de
> http://www.wapme-systems.de/
> -------------------------------------------------------------------
> 
-- 
Thanks,
Alex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.