In this loop
while(client.available()) {
Serial.write(client.read());
buffer[ctr] = client.read();
you're using client.read() twice, so the buffer gets only every second character.
A solution could be:
while(client.available()) {
int c = client.read();
Serial.write(c);
buffer[ctr] = c;