Usually this is pretty easy:How to detect if the buffer is too small for strcpy()?
Code:void do_copy(char* str) { char buffer[BUFFER_SIZE]; size_t size = strlen(str); if(size >= BUFFER_SIZE) { /* Error, buffer is too small */ } else { strcpy(buffer, str); } // ... }