Am Dienstag 17 August 2010, 14:20:28 schrieb Luiz Augusto von Dentz: > I took a look and basically all transport that don't have an > ops->init, like OBEX_TRANS_FD, or it doesn't init trans->data will > most likely going to crash on custom_set_data. This was cause because > gwobex is apparently misusing OBEX_SetCustomData when in fact it using > FD transport type, but openobex should not crash either so I guess we > need a check for that.
We may do this. But it needs a change to indicate failure, then (currently SetCustomData returns void). The comment on SetCustomData is clear enough. --- commit 7454216fb087d26167c783132a7280141c379a45 Author: Hendrik Sattler <p...@hendrik-sattler.de> Date: Sun Aug 22 16:47:05 2010 +0200 Check that SetCustomData is only used with OBEX_TRANS_CUSTOM diff --git a/include/openobex/obex.h b/include/openobex/obex.h index dae4bf6..5bead73 100644 --- a/include/openobex/obex.h +++ b/include/openobex/obex.h @@ -76,7 +76,7 @@ OPENOBEX_SYMBOL(int) OBEX_SetTransportMTU(obex_t *self, uint16_t mtu_rx, ui OPENOBEX_SYMBOL(int) OBEX_GetFD(obex_t *self); OPENOBEX_SYMBOL(int) OBEX_RegisterCTransport(obex_t *self, obex_ctrans_t *ctrans); -OPENOBEX_SYMBOL(void) OBEX_SetCustomData(obex_t *self, void * data); +OPENOBEX_SYMBOL(int ) OBEX_SetCustomData(obex_t *self, void * data); OPENOBEX_SYMBOL(void *) OBEX_GetCustomData(obex_t *self); OPENOBEX_SYMBOL(int) OBEX_TransportConnect(obex_t *self, struct sockaddr *saddr, int addlen); diff --git a/lib/obex.c b/lib/obex.c index 45d511a..6399538 100644 --- a/lib/obex.c +++ b/lib/obex.c @@ -842,6 +842,7 @@ char * CALLAPI OBEX_ResponseToString(int rsp) Set customdata of an OBEX handle. \param self OBEX handle \param data Custom Transport data + \return 0 on success, -1 on error Note : this call is *reserved* to the Custom Transport and should not be use by the user/client. It allow to update the Custom Transport data @@ -853,10 +854,13 @@ char * CALLAPI OBEX_ResponseToString(int rsp) - Jean II */ LIB_SYMBOL -void CALLAPI OBEX_SetCustomData(obex_t *self, void *data) +int CALLAPI OBEX_SetCustomData(obex_t *self, void *data) { - obex_return_if_fail(self != NULL); + obex_return_val_if_fail(self == NULL, -1); + obex_return_val_if_fail(self->trans.type != OBEX_TRANS_CUSTOM, -1); + custom_set_data(self, data); + return 0; } /** @@ -867,7 +871,9 @@ void CALLAPI OBEX_SetCustomData(obex_t *self, void *data) LIB_SYMBOL void * CALLAPI OBEX_GetCustomData(obex_t *self) { - obex_return_val_if_fail(self != NULL, 0); + obex_return_val_if_fail(self == NULL, NULL); + obex_return_val_if_fail(self->trans.type != OBEX_TRANS_CUSTOM, NULL); + return custom_get_data(self); } ------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev _______________________________________________ Openobex-users mailing list Openobex-users@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/openobex-users