title: Preventing buffer overflow in C
body: <p>Is there any way to prevent buffer overflow in C ?
  If I can't determine the string length how can I know when to stop ?</p>
  
  <pre><code>x = malloc(strlen(unsafe_string) + 1);
  memcpy(x, unsafe_string, strlen(unsafe_string) + 1);
  </code></pre>