Changeset 138

Show
Ignore:
Timestamp:
04/21/06 00:01:54 (3 years ago)
Author:
abauer
Message:

Fix a problem when using DELETE commands

Fix a problem when the statuses to commands
are larger then the commands itself

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/6620-branch/libsyncml/parser/sml_xml_assm.c

    r136 r138  
    14621462                         
    14631463                buffersize += xmlBufferLength(status->buffer) - 1; 
    1464                 if (maxsize && buffersize > maxsize) 
    1465                       break; 
     1464                //if (maxsize && buffersize > maxsize) 
     1465                //    break; 
    14661466                xmlTextWriterWriteRawLen(assm->writer, xmlBufferContent(status->buffer), xmlBufferLength(status->buffer) - 1); 
    14671467        } 
  • branches/6620-branch/libsyncml/sml_elements.c

    r127 r138  
    316316} 
    317317 
     318/* If data is NULL, this call is the same if smlItemNew */ 
    318319SmlItem *smlItemNewForData(const char *data, unsigned int size, SmlError **error) 
    319320{ 
     
    323324        if (!item) 
    324325                goto error; 
    325                  
    326         if (!smlItemAddData(item, data, size, error)) 
    327                 goto error_free_item; 
     326         
     327        if (data) { 
     328                if (!smlItemAddData(item, data, size, error)) 
     329                        goto error_free_item; 
     330        } 
    328331         
    329332        smlTrace(TRACE_EXIT, "%s: %p", __func__, item); 
  • branches/6620-branch/libsyncml/sml_parse.c

    r127 r138  
    721721 * @param assm The assembler 
    722722 * @param status The command to add 
     723 * @param force If set to TRUE, libsyncml will ignore if the outgoing limit has been reached 
    723724 * @param error A pointer to an error struct 
    724725 * @returns SML_ASSEMBLER_RESULT_OK if the status was added ok, SML_ASSEMBLER_RESULT_MISMATCH 
     
    726727 *  
    727728 */ 
    728 SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error) 
    729 { 
    730         smlTrace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, assm, status, error); 
     729SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, SmlError **error) 
     730{ 
     731        smlTrace(TRACE_ENTRY, "%s(%p, %p, %i, %p)", __func__, assm, status, force, error); 
    731732        smlAssert(assm); 
    732733        smlAssert(status); 
     
    738739                goto error; 
    739740         
    740          
    741         /* Lets see if the new buffer is small enough */ 
    742         int limit = smlAssemblerGetLimit(assm); 
    743         if (limit) { 
    744                 /* Now check the size */ 
    745                 unsigned int size = 0; 
    746                 if (!(size = smlAssemblerCheckSize(assm, FALSE, error))) 
    747                         goto error; 
    748                  
    749                 if (size > limit) { 
    750                         /* The status does not fit. Remove it again */ 
    751                         if (!assm->functions.rem_status(assm->assm_userdata, error)) 
     741        if (!force) { 
     742                /* Lets see if the new buffer is small enough */ 
     743                int limit = smlAssemblerGetLimit(assm); 
     744                if (limit) { 
     745                        /* Now check the size */ 
     746                        unsigned int size = 0; 
     747                        if (!(size = smlAssemblerCheckSize(assm, FALSE, error))) 
    752748                                goto error; 
    753749                         
    754                         smlTrace(TRACE_EXIT, "%s: Mismatch", __func__); 
    755                         return SML_ASSEMBLER_RESULT_MISMATCH; 
     750                        if (size > limit) { 
     751                                /* The status does not fit. Remove it again */ 
     752                                if (!assm->functions.rem_status(assm->assm_userdata, error)) 
     753                                        goto error; 
     754                                 
     755                                smlTrace(TRACE_EXIT, "%s: Mismatch", __func__); 
     756                                return SML_ASSEMBLER_RESULT_MISMATCH; 
     757                        } 
    756758                } 
    757759        } 
     
    766768        smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 
    767769        return SML_ASSEMBLER_RESULT_ERROR; 
     770} 
     771 
     772SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error) 
     773{ 
     774        return smlAssemblerAddStatusFull(assm, status, FALSE, error); 
    768775} 
    769776 
  • branches/6620-branch/libsyncml/sml_parse.h

    r127 r138  
    101101SmlBool smlAssemblerRun(SmlAssembler *assm, char **data, unsigned int *size, SmlBool *end, SmlBool final, SmlError **error); 
    102102SmlAssemblerResult smlAssemblerAddStatus(SmlAssembler *assm, SmlStatus *status, SmlError **error); 
     103SmlAssemblerResult smlAssemblerAddStatusFull(SmlAssembler *assm, SmlStatus *status, SmlBool force, SmlError **error); 
    103104SmlAssemblerResult smlAssemblerReserveStatus(SmlAssembler *assm, unsigned int cmdRef, unsigned int msgRef, unsigned int cmdID, SmlError **error); 
    104105SmlBool smlAssemblerAddHeader(SmlAssembler *assm, SmlSession *session, SmlError **error); 
  • branches/6620-branch/libsyncml/sml_session.c

    r127 r138  
    543543                        } 
    544544                         
     545                        /* We ignore if the added status violates the size limitation if 
     546                         * a incoming buffer for a large object is open. the problem is that 
     547                         * the status for the chunk has to go into the next message AND the status 
     548                         * MUST be in the same order as the original commands. so the only solution is 
     549                         * to send all statuses and ignore the size. */ 
     550                         
    545551                        /* Now we can try to add the status to the assembler */ 
    546                         switch (smlAssemblerAddStatus(session->assembler, status, &error)) { 
     552                        switch (smlAssemblerAddStatusFull(session->assembler, status, session->incomingBuffer ? TRUE : FALSE, &error)) { 
    547553                                case SML_ASSEMBLER_RESULT_OK: 
    548554                                        /* We successfully added the status */ 
     
    925931        if (final) { 
    926932                if (session->pendingReplies) { 
    927                         smlErrorSet(error, SML_ERROR_GENERIC, "Didnt receive a reply for a pending status"); 
     933                        SmlPendingStatus *pending = (SmlPendingStatus *)session->pendingReplies->data; 
     934                        smlErrorSet(error, SML_ERROR_GENERIC, "Didnt receive a reply for pending status (cmdID %i, msgID %i)", pending->cmdID, pending->msgID); 
    928935                        _smlSessionFreePendingReplies(session); 
    929936                        goto error;