Hi guys i have a programm which receives 1 byte at a time from a server and writes it in a buffer and then prints it
but somewhow i get this stack smashing detected
Buffersize is 1
int total_bytes = 0;
int bytes_received = 0;
while (1) {
bytes_received = recv(socket_descriptor, buffer + total_bytes, BUFFFER, 0);
if (bytes_received <= 0) {
// Handle error or connection closure
break;
}
if (buffer[total_bytes] == '\n') {
buffer[total_bytes + 1] = '\0';
break;
}
total_bytes++;
}
printf ("Nachricht erhalten: %s\n", buffer);