Re: WARNING: SMPP: PDU element <password> to long (length is 9, should be 9)
Aarno Syvänen <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
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.
Aarno
Aarno
On 11.8.2004, at 01:17, Stipe Tolj wrote:
> Stipe Tolj wrote:
>
>> Ok, now about the warning. I see this in gw/smsc/smpp_pdu.c:236:
>> ...
>> #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); \
>> 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');
>> ...
>> Which means the warning will go out even when we have the max octets
>> in the pdu field.
>> Question should be: why do we compare >= and not only > ???
>> I don't see any good reason on the equal compare here.
>
> ok, confirmed that I have been muggling arround that code, see:
> http://www.kannel.org/cgi-bin/viewcvs.cgi/gateway/gw/smsc/
> smpp_pdu.c.diff?r1=1.1&r2=1.2
>
> but I actualy don't see a reason why we shouldn't change the if
> statement from >= compare to pure > compare.
>
> Any objections here?
>
> Sitpe
>
> 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/
> -------------------------------------------------------------------
>
> -----BEGIN PGP PUBLIC KEY BLOCK-----
> Version: GnuPG v1.2.2 (Cygwin)
>
> mIsEP6mcYwEEAMDnUiUwrbb+xwTFWN6TxF2+XZu7/alwJMeCwMBRvXtPZqfjpPhS
> OkBpU0F4TrVuugz1HINTSaJTYq10AzDQXp5NkyWgckqW79nPAWuOX0dicbJk+cN2
> nM2TI4KaxUDe6u8hghNEnH/i2lXsUu9apnP/iixzV81VC2je3uc9hZpnAAYptEVT
> dGlwZSBUb2xqIChUZWNobm9sb2d5IENlbnRlciAmIFJlc2VhcmNoIExhYikgPHRv
> bGpAd2FwbWUtc3lzdGVtcy5kZT6ItAQTAQIAHgUCP6mcYwIbAwYLCQgHAwIDFQID
> AxYCAQIeAQIXgAAKCRABV0w1BqPYRuSqA/wPzsQxao2YePENCtgRTrO86U6zg3sl
> OcS6CJFI4FZP5h/xD3GRsNH1+MPSvZlomDdpFnr547DGz/Kq9MXuQwVvlVig5yWZ
> K5dtKp1r5YLhxJQBhfirZbRFFnYmf19f18J8OoS28tuFVftDl1AIwJS3HLyBTv6H
> g2HyLAEKQIp30Q==
> =aYCI
> -----END PGP PUBLIC KEY BLOCK-----
>