EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: [Merge] ~dirk.zimoch/epics-base:fix_zero_size_arrays into epics-base:7.0
From: Dirk Zimoch via Core-talk <core-talk at aps.anl.gov>
To: mp+386175 at code.launchpad.net
Date: Wed, 15 Jul 2020 15:44:20 -0000
more inline comment.

Diff comments:

> diff --git a/modules/database/src/ioc/db/dbTest.c b/modules/database/src/ioc/db/dbTest.c
> index 1193954..25782a2 100644
> --- a/modules/database/src/ioc/db/dbTest.c
> +++ b/modules/database/src/ioc/db/dbTest.c
> @@ -379,16 +380,41 @@ long dbpf(const char *pname,const char *pvalue)
>          return -1;
>      }
>  
> -    if (addr.no_elements > 1 &&
> -        (addr.dbr_field_type == DBR_CHAR || addr.dbr_field_type == DBR_UCHAR)) {
> -        dbrType = addr.dbr_field_type;
> -        n = strlen(pvalue) + 1;
> -    }
> -    else {
> -        dbrType = DBR_STRING;
> +    if (addr.no_elements > 1) {
> +        if (addr.dbr_field_type == DBR_CHAR || addr.dbr_field_type == DBR_UCHAR) {
> +            dbrType = addr.dbr_field_type;
> +            n = (long)strlen(pvalue) + 1;
> +        } else {
> +            const char *p = pvalue;
> +
> +            for (n = 0; *p && n < addr.no_elements; n++) {
> +                while (isspace(*p)) p++;
> +                while (*p && !isspace(*p)) {
> +                    if (p[0] == '\\' && p[1]) p++;
> +                    p++;
> +                }
> +            }
> +            p = pvalue;
> +            array = dbCalloc(n, MAX_STRING_SIZE);

'dbl' calls dbCalloc() as well. And epicsStrDup(), which calls mallocMustSucceed().
And dbGetString() is used a lot in this file and calls dbCalloc() as well via dbMsgCpy() and getpMessage().

> +            for (n = 0; *p && n < addr.no_elements; n++) {
> +                char* c = &array[n*MAX_STRING_SIZE];
> +                while (isspace(*p)) p++;
> +                pvalue = p;
> +                while (*p && !isspace(*p)) {
> +                    if (p[0] == '\\' && p[1]) p++;
> +                    if (c >= &array[(n+1)*MAX_STRING_SIZE]-1) {
> +                        printf("Value [%ld] %.*s too long\n", n, (int)(p-pvalue), pvalue);
> +                        free(array);
> +                        return -1;
> +                    }
> +                    *c++=*p++;
> +                }
> +            }
> +            pvalue = array;
> +        }
>      }
> -
> -    status = dbPutField(&addr, dbrType, pvalue, (long) n);
> +    status = dbPutField(&addr, dbrType, pvalue, n);
> +    free(array);
>      dbgf(pname);
>      return status;
>  }


-- 
https://code.launchpad.net/~dirk.zimoch/epics-base/+git/epics-base/+merge/386175
Your team EPICS Core Developers is subscribed to branch epics-base:7.0.

References:
[Merge] ~dirk.zimoch/epics-base:fix_zero_size_arrays into epics-base:7.0 Dirk Zimoch via Core-talk

Navigate by Date:
Prev: Re: [Merge] ~dirk.zimoch/epics-base:fix_zero_size_arrays into epics-base:7.0 Dirk Zimoch via Core-talk
Next: Build failed: EPICS Base 7 base-7.0-50 AppVeyor via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: [Merge] ~dirk.zimoch/epics-base:fix_zero_size_arrays into epics-base:7.0 Dirk Zimoch via Core-talk
Next: Re: [Merge] ~dirk.zimoch/epics-base:fix_zero_size_arrays into epics-base:7.0 Dirk Zimoch via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
ANJ, 16 Jul 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·