Diff for /embedaddon/miniupnpd/upnpreplyparse.c between versions 1.1 and 1.1.1.2

version 1.1, 2012/02/21 23:16:02 version 1.1.1.2, 2012/05/29 12:55:57
Line 1 Line 1
 /* $Id$ */  /* $Id$ */
 /* MiniUPnP project  /* MiniUPnP project
  * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/   * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
 * (c) 2006 Thomas Bernard  * (c) 2006-2011 Thomas Bernard 
  * This software is subject to the conditions detailed   * This software is subject to the conditions detailed
  * in the LICENCE file provided within the distribution */   * in the LICENCE file provided within the distribution */
   
Line 27  NameValueParserGetData(void * d, const char * datas, i Line 27  NameValueParserGetData(void * d, const char * datas, i
 {  {
     struct NameValueParserData * data = (struct NameValueParserData *)d;      struct NameValueParserData * data = (struct NameValueParserData *)d;
     struct NameValue * nv;      struct NameValue * nv;
    nv = malloc(sizeof(struct NameValue));        if(strcmp(data->curelt, "NewPortListing") == 0)
    if(l>63)        {
        l = 63;                /* specific case for NewPortListing which is a XML Document */
    strncpy(nv->name, data->curelt, 64);                data->portListing = malloc(l + 1);
        nv->name[63] = '\0';                if(!data->portListing)
    memcpy(nv->value, datas, l);                {
    nv->value[l] = '\0';                        /* malloc error */
    LIST_INSERT_HEAD( &(data->head), nv, entries);                        return;
                 }
                 memcpy(data->portListing, datas, l);
                 data->portListing[l] = '\0';
                 data->portListingLength = l;
         }
         else
         {
                 /* standard case. Limited to 63 chars strings */
             nv = malloc(sizeof(struct NameValue));
             if(l>63)
                 l = 63;
             strncpy(nv->name, data->curelt, 64);
                 nv->name[63] = '\0';
             memcpy(nv->value, datas, l);
             nv->value[l] = '\0';
             LIST_INSERT_HEAD( &(data->head), nv, entries);
         }
 }  }
   
 void  void
 ParseNameValue(const char * buffer, int bufsize,  ParseNameValue(const char * buffer, int bufsize,
                    struct NameValueParserData * data)               struct NameValueParserData * data)
 {  {
     struct xmlparser parser;      struct xmlparser parser;
     LIST_INIT(&(data->head));      LIST_INIT(&(data->head));
           data->portListing = NULL;
           data->portListingLength = 0;
     /* init xmlparser object */      /* init xmlparser object */
     parser.xmlstart = buffer;      parser.xmlstart = buffer;
     parser.xmlsize = bufsize;      parser.xmlsize = bufsize;
Line 58  void Line 77  void
 ClearNameValueList(struct NameValueParserData * pdata)  ClearNameValueList(struct NameValueParserData * pdata)
 {  {
     struct NameValue * nv;      struct NameValue * nv;
           if(pdata->portListing)
           {
                   free(pdata->portListing);
                   pdata->portListing = NULL;
                   pdata->portListingLength = 0;
           }
     while((nv = pdata->head.lh_first) != NULL)      while((nv = pdata->head.lh_first) != NULL)
     {      {
         LIST_REMOVE(nv, entries);          LIST_REMOVE(nv, entries);

Removed from v.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>