1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

arith.c: harmonise source code formatting (re: 593a5a8b)

This commit is contained in:
Martijn Dekker 2021-09-13 00:35:01 +02:00
parent bdc3069bfd
commit 44bdb3fbfc

View file

@ -539,25 +539,28 @@ Sfdouble_t sh_strnum(register const char *str, char** ptr, int mode)
{ {
d = 0.0; d = 0.0;
last = (char*)str; last = (char*)str;
} else { }
else
{
errno = 0; errno = 0;
d = strtonll(str,&last,&base,-1); d = strtonll(str,&last,&base,-1);
if (*last && !shp->inarith && sh_isstate(SH_INIT)) { if(*last && !shp->inarith && sh_isstate(SH_INIT))
{
/* This call is to handle "base#value" literals if we're importing untrusted env vars. */ /* This call is to handle "base#value" literals if we're importing untrusted env vars. */
errno = 0; errno = 0;
d = strtonll(str, &last, NULL, -1); d = strtonll(str, &last, NIL(char*), -1);
} }
if(*last || errno) if(*last || errno)
{ {
if (sh_isstate(SH_INIT)) { if(sh_isstate(SH_INIT))
/* /*
* Initializing means importing untrusted env vars. The string does not appear to be * Initializing means importing untrusted env vars. The string does not appear to be
* a recognized numeric literal, so give up. We can't safely call strval(), because * a recognized numeric literal, so give up. We can't safely call strval(), because
* that allows arbitrary expressions, causing security vulnerability CVE-2019-14868. * that allows arbitrary expressions, causing security vulnerability CVE-2019-14868.
*/ */
d = 0.0; d = 0.0;
} else { else
{
if(!last || *last!='.' || last[1]!='.') if(!last || *last!='.' || last[1]!='.')
d = strval(shp,str,&last,arith,mode); d = strval(shp,str,&last,arith,mode);
if(!ptr && *last && mode>0) if(!ptr && *last && mode>0)
@ -566,9 +569,9 @@ Sfdouble_t sh_strnum(register const char *str, char** ptr, int mode)
UNREACHABLE(); UNREACHABLE();
} }
} }
} else if (!d && *str=='-') {
d = -0.0;
} }
else if(!d && *str=='-')
d = -0.0;
} }
if(ptr) if(ptr)
*ptr = last; *ptr = last;