Diff for /libaitcfg/src/queue.c between versions 1.1 and 1.2

version 1.1, 2008/08/28 13:17:41 version 1.2, 2009/09/09 09:07:31
Line 1 Line 1
   /*************************************************************************
   * (C) 2008 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
   *  by Michael Pounov <misho@openbsd-bg.org>
   *
   * $Author$
   * $Id$
   *
   *************************************************************************/
 #include "global.h"  #include "global.h"
 #include "aitcfg.h"  #include "aitcfg.h"
   
Line 166  int cfg_SetAttribute(sl_config * __restrict cfg, const Line 174  int cfg_SetAttribute(sl_config * __restrict cfg, const
                                 free(av);                                  free(av);
                                 return -1;                                  return -1;
                         } else {                          } else {
                                memset(av->psSection, 0, strlen((char*) csSec) + 1);                                strlcpy((char*) av->psSection, (char*) csSec, strlen((char*) csSec) + 1);
                                strcpy((char*) av->psSection, (char*) csSec); 
                         }                          }
                 } else                  } else
                         av->psSection = NULL;                          av->psSection = NULL;
Line 180  int cfg_SetAttribute(sl_config * __restrict cfg, const Line 187  int cfg_SetAttribute(sl_config * __restrict cfg, const
                         free(av);                          free(av);
                         return -1;                          return -1;
                 } else {                  } else {
                        memset(av->psAttribute, 0, strlen((char*) csAttr) + 1);                        strlcpy((char*) av->psAttribute, (char*) csAttr, strlen((char*) csAttr) + 1);
                        strcpy((char*) av->psAttribute, (char*) csAttr); 
                 }                  }
                 // added value to element                  // added value to element
                 if (csVal && *csVal) {                  if (csVal && *csVal) {
Line 193  int cfg_SetAttribute(sl_config * __restrict cfg, const Line 199  int cfg_SetAttribute(sl_config * __restrict cfg, const
                                 free(av);                                  free(av);
                                 return -1;                                  return -1;
                         } else {                          } else {
                                memset(av->psValue, 0, strlen((char*) csVal) + 1);                                strlcpy((char*) av->psValue, (char*) csVal, strlen((char*) csVal) + 1);
                                strcpy((char*) av->psValue, (char*) csVal); 
                         }                          }
                 } else {                  } else {
                         av->psValue = malloc(1);                          av->psValue = malloc(1);
Line 207  int cfg_SetAttribute(sl_config * __restrict cfg, const Line 212  int cfg_SetAttribute(sl_config * __restrict cfg, const
   
         if (strcmp((char*) csVal, (char*) av->psValue)) {          if (strcmp((char*) csVal, (char*) av->psValue)) {
                 av->psValue = realloc(av->psValue, strlen((char*) csVal) + 1);                  av->psValue = realloc(av->psValue, strlen((char*) csVal) + 1);
                memset(av->psValue, 0, strlen((char*) csVal) + 1);                strlcpy((char*) av->psValue, (char*) csVal, strlen((char*) csVal) + 1);
                strcpy((char*) av->psValue, (char*) csVal); 
   
                 // Update element                  // Update element
                 return 1;                  return 1;
Line 260  int cfg_LoadAttribute(sl_config * __restrict cfg, cons Line 264  int cfg_LoadAttribute(sl_config * __restrict cfg, cons
         if (!cfg || !csAttr || !ValLen || !psVal)          if (!cfg || !csAttr || !ValLen || !psVal)
                 return -1;                  return -1;
   
         memset(psVal, 0, ValLen);  
         av = SelectAttribute(cfg, csSec, csAttr);          av = SelectAttribute(cfg, csSec, csAttr);
         if (!av) {          if (!av) {
                 if (csDefValue) {                  if (csDefValue) {
                        strncpy((char*) psVal, csDefValue, ValLen - 1);                        strlcpy((char*) psVal, csDefValue, ValLen);
                         ret = strlen((char*) psVal);                          ret = strlen((char*) psVal);
                 }                  }
   
Line 273  int cfg_LoadAttribute(sl_config * __restrict cfg, cons Line 276  int cfg_LoadAttribute(sl_config * __restrict cfg, cons
   
         if (!av->psValue || !*av->psValue) {          if (!av->psValue || !*av->psValue) {
                 if (csDefValue) {                  if (csDefValue) {
                        strncpy((char*) psVal, csDefValue, ValLen - 1);                        strlcpy((char*) psVal, csDefValue, ValLen);
                         ret = strlen((char*) psVal);                          ret = strlen((char*) psVal);
                 }                  }
         } else {          } else {
                strncpy((char*) psVal, (char*) av->psValue, ValLen - 1);                strlcpy((char*) psVal, (char*) av->psValue, ValLen);
                 ret = strlen((char*) psVal);                  ret = strlen((char*) psVal);
         }          }
   

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


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