From: Yasuo Ohgaki Date: Mon, 25 Nov 2002 01:38:29 +0000 (+0000) Subject: Cleanup state=4 and avoid using sscanf() X-Git-Tag: RELEASE_1_0b2~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c851cba19221b9e03c34afdbd8396a7f5f9b6bf;p=php Cleanup state=4 and avoid using sscanf() --- diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f82e1be7af..ffa6d23b0d 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2708,15 +2708,13 @@ static unsigned char * php_pgsql_unescape_bytea(unsigned char *strtext, size_t * case 3: if (isdigit(*sp)) /* state=4 */ { - unsigned int v,i; - unsigned char buf[4]; /* 000 + '\0' */ - + unsigned char *start, *end, buf[4]; /* 000 + '\0' */ + bp -= 3; - for (i = 0; i < 3; i++) - buf[i] = *((sp-2)+i); - buf[i] = '\0'; - sscanf(buf, "%03o", &v); - *bp = v; + memcpy(buf, sp-2, 3); + buf[3] = '\0'; + start = buf; + *bp = (unsigned char)strtoul(start, &end, 8); buflen -= 3; state = 0; }