]> granicus.if.org Git - php/commitdiff
Cleanup state=4 and avoid using sscanf()
authorYasuo Ohgaki <yohgaki@php.net>
Mon, 25 Nov 2002 01:38:29 +0000 (01:38 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Mon, 25 Nov 2002 01:38:29 +0000 (01:38 +0000)
ext/pgsql/pgsql.c

index f82e1be7afffea254595bc9761ee9401e531c0b2..ffa6d23b0d991950ef4ebd08503358afe34388bd 100644 (file)
@@ -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;
                                }