1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
--- ext/standard/scanf.c.orig 2006-01-01 13:46:58.000000000 +0000
+++ ext/standard/scanf.c 2006-08-10 23:00:19.000000000 +0100
@@ -732,7 +732,7 @@
if (*end == '$') {
format = end+1;
ch = format++;
- objIndex = varStart + value;
+ objIndex = varStart + value - 1;
}
}
@@ -762,8 +762,10 @@
switch (*ch) {
case 'n':
if (!(flags & SCAN_SUPPRESS)) {
- if (numVars) {
- current = args[objIndex++];
+ if (numVars && objIndex >= argCount) {
+ break;
+ } else if (numVars) {
+ current = args[objIndex++];
zval_dtor( *current );
ZVAL_LONG( *current, (long)(string - baseString) );
} else {
@@ -883,8 +885,10 @@
}
}
if (!(flags & SCAN_SUPPRESS)) {
- if (numVars) {
- current = args[objIndex++];
+ if (numVars && objIndex >= argCount) {
+ break;
+ } else if (numVars) {
+ current = args[objIndex++];
zval_dtor( *current );
ZVAL_STRINGL( *current, string, end-string, 1);
} else {
@@ -922,7 +926,9 @@
goto done;
}
if (!(flags & SCAN_SUPPRESS)) {
- if (numVars) {
+ if (numVars && objIndex >= argCount) {
+ break;
+ } else if (numVars) {
current = args[objIndex++];
zval_dtor( *current );
ZVAL_STRINGL( *current, string, end-string, 1);
@@ -1079,8 +1085,10 @@
value = (int) (*fn)(buf, NULL, base);
if ((flags & SCAN_UNSIGNED) && (value < 0)) {
sprintf(buf, "%u", value); /* INTL: ISO digit */
- if (numVars) {
- /* change passed value type to string */
+ if (numVars && objIndex >= argCount) {
+ break;
+ } else if (numVars) {
+ /* change passed value type to string */
current = args[objIndex++];
convert_to_string( *current );
ZVAL_STRING( *current, buf, 1 );
@@ -1088,7 +1096,9 @@
add_index_string(*return_value, objIndex++, buf, 1);
}
} else {
- if (numVars) {
+ if (numVars && objIndex >= argCount) {
+ break;
+ } else if (numVars) {
current = args[objIndex++];
convert_to_long( *current );
Z_LVAL(**current) = value;
@@ -1196,7 +1206,9 @@
double dvalue;
*end = '\0';
dvalue = zend_strtod(buf, NULL);
- if (numVars) {
+ if (numVars && objIndex >= argCount) {
+ break;
+ } else if (numVars) {
current = args[objIndex++];
convert_to_double( *current );
Z_DVAL_PP( current ) = dvalue;
|