equal
deleted
inserted
replaced
103 cap = 4; |
103 cap = 4; |
104 for (j = 0; j < cap; i++, j++) |
104 for (j = 0; j < cap; i++, j++) |
105 { |
105 { |
106 c = b85dec[(int)*text++] - 1; |
106 c = b85dec[(int)*text++] - 1; |
107 if (c < 0) |
107 if (c < 0) |
108 return PyErr_Format(PyExc_ValueError, "Bad base85 character at position %d", i); |
108 return PyErr_Format( |
|
109 PyExc_ValueError, |
|
110 "Bad base85 character at position %d", i); |
109 acc = acc * 85 + c; |
111 acc = acc * 85 + c; |
110 } |
112 } |
111 if (i++ < len) |
113 if (i++ < len) |
112 { |
114 { |
113 c = b85dec[(int)*text++] - 1; |
115 c = b85dec[(int)*text++] - 1; |
114 if (c < 0) |
116 if (c < 0) |
115 return PyErr_Format(PyExc_ValueError, "Bad base85 character at position %d", i); |
117 return PyErr_Format( |
|
118 PyExc_ValueError, |
|
119 "Bad base85 character at position %d", i); |
116 /* overflow detection: 0xffffffff == "|NsC0", |
120 /* overflow detection: 0xffffffff == "|NsC0", |
117 * "|NsC" == 0x03030303 */ |
121 * "|NsC" == 0x03030303 */ |
118 if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) |
122 if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) |
119 return PyErr_Format(PyExc_ValueError, "Bad base85 sequence at position %d", i); |
123 return PyErr_Format( |
|
124 PyExc_ValueError, |
|
125 "Bad base85 sequence at position %d", i); |
120 acc += c; |
126 acc += c; |
121 } |
127 } |
122 |
128 |
123 cap = olen < 4 ? olen : 4; |
129 cap = olen < 4 ? olen : 4; |
124 olen -= cap; |
130 olen -= cap; |