Hi all, Oded is right here I guess. bearerbox should not panic if someone injects data (via sendsms interface) that is out of SMPP specification scope, which is 20 octets for the source and destination number.
I'd suggest not to copy at the place Oded does, but in smpp_pdu.c:smpp_pdu_pack() by taking out the assertion check and throwing an error to the log and copy the Octstrs to the desired length, please see patch attached. Votes for this solution in favour of Odeds? benefits: - don't panic in case the PDU type is not known anyway. - log a warning if a given PDU field is too long and cut it to the specified (by spec) length. BTW, we should not #define constants of SMPP that are explicitely 'defined' by the .def file anyway. So the 21 length for source and destination number is already a #define in this semantical way and hence we should *not* use #defined things in .def again. Oded, can you try this patch instead of your own that has been commited and vote for one of both. I'm definetly +1 for this and -1 for Odeds (sorry :), but it's a conceptual clash in my point of view. Stipe RCS file: /home/cvs/gateway/gw/smsc/smpp_pdu.c,v retrieving revision 1.1 diff -r1.1 smpp_pdu.c 104c104 < panic(0, "Unknown SMPP_PDU type, internal error while destroying."); --- > error(0, "Unknown SMPP_PDU type, internal error while destroying."); 129c129 < panic(0, "Unknown SMPP_PDU type, internal error while packing."); --- > error(0, "Unknown SMPP_PDU type, internal error while packing."); 136,138c136,147 < gw_assert(octstr_len(p->name) < max_octets); \ < if (p->name != NULL) octstr_append(os, p->name); \ < octstr_append_char(os, '\0'); --- > if (p->name != NULL) { \ > if (octstr_len(p->name) >= max_octets) { \ > warning(0, "SMPP: PDU element <%s> to long " \ > "(length is %d, 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'); 145c154 < panic(0, "Unknown SMPP_PDU type, internal error while packing."); --- > error(0, "Unknown SMPP_PDU type, internal error while packing."); 192c201 < panic(0, "Unknown SMPP_PDU type, internal error while unpacking."); --- > error(0, "Unknown SMPP_PDU type, internal error while unpacking."); [EMAIL PROTECTED] ------------------------------------------------------------------- Wapme Systems AG Vogelsanger Weg 80 40470 Düsseldorf Tel: +49-211-74845-0 Fax: +49-211-74845-299 E-Mail: [EMAIL PROTECTED] Internet: http://www.wapme-systems.de ------------------------------------------------------------------- wapme.net - wherever you are