| 126 | |
| 127 | |
| 128 | void blb::BLB_check_well_formed(Jrd::thread_db* tdbb, const dsc* desc) |
| 129 | { |
| 130 | /************************************** |
| 131 | * |
| 132 | * b l b : : c h e c k _ w e l l _ f o r m e d |
| 133 | * |
| 134 | ************************************** |
| 135 | * |
| 136 | * Functional description |
| 137 | * Check if a text BLOB is well formed. |
| 138 | * |
| 139 | **************************************/ |
| 140 | |
| 141 | SET_TDBB(tdbb); |
| 142 | |
| 143 | // Need to verify this to work in database creation, as the charsets didn't exist yet. |
| 144 | if (desc->getCharSet() == CS_NONE || desc->getCharSet() == CS_BINARY) |
| 145 | return; |
| 146 | |
| 147 | CharSet* charSet = INTL_charset_lookup(tdbb, desc->getCharSet()); |
| 148 | |
| 149 | if (!charSet->shouldCheckWellFormedness()) |
| 150 | return; |
| 151 | |
| 152 | HalfStaticArray<UCHAR, BUFFER_MEDIUM> buffer; |
| 153 | ULONG pos = 0; |
| 154 | |
| 155 | while (!(blb_flags & BLB_eof)) |
| 156 | { |
| 157 | const ULONG len = BLB_get_data(tdbb, |
| 158 | buffer.getBuffer(buffer.getCapacity()) + pos, buffer.getCapacity() - pos, false); |
| 159 | buffer.resize(pos + len); |
| 160 | |
| 161 | if (charSet->wellFormed(pos + len, buffer.begin(), &pos)) |
| 162 | pos = 0; |
| 163 | else |
| 164 | { |
| 165 | if (pos == 0) |
| 166 | status_exception::raise(Arg::Gds(isc_malformed_string)); |
| 167 | else |
| 168 | { |
| 169 | buffer.removeCount(0, pos); |
| 170 | pos = buffer.getCount(); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (pos != 0) |
| 176 | status_exception::raise(Arg::Gds(isc_malformed_string)); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | bool blb::BLB_close(thread_db* tdbb) |
no test coverage detected