summaryrefslogtreecommitdiff
path: root/ext/pgsql/pgsql.c
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-11-25 01:38:29 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-11-25 01:38:29 +0000
commit5c851cba19221b9e03c34afdbd8396a7f5f9b6bf (patch)
tree5b9a5b67afda292948ff92f16a82dadaa884f96a /ext/pgsql/pgsql.c
parent6aa90a75bd07ae740038e5f5db4225cdc0ff8b19 (diff)
downloadphp-git-5c851cba19221b9e03c34afdbd8396a7f5f9b6bf.tar.gz
Cleanup state=4 and avoid using sscanf()
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r--ext/pgsql/pgsql.c14
1 files changed, 6 insertions, 8 deletions
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;
}