title: Supply a string that is not null terminated to strcpy
body: <p>Here is the code</p>
  
  <pre><code>smem_dmp(char *name, char content[])
  {                     
          int i;
          int len = strlen(content);       
  
          printf("%s\n\n", name);
  
          for(i = 0; i &lt; len; i++)
          {
               printf("%c\t%p\n", content[i], &amp;content[i] );     
          }
  
          printf("Done\n\n");
  }
  
  print_bar()
  {
       printf("********************************************************************\n");
  }
  
  int main(int argc, char *argv[])
  {
      char a[16];
      char b[16];
  
  
      strcpy(a, "abcdefghijklmnop");
      printf("a = %s\nb = %s\n\n",a,b);
  
      smem_dmp("A", a);
      smem_dmp("B", b);
  
      print_bar();
  
      strcpy(b, "ABCDEFGHILKLMNOP");
      printf("a = %s\nb = %s\n\n",a,b);
  
      smem_dmp("A", a);
      smem_dmp("B", b);
  
      system("PAUSE");    
      return 0;
  }
  </code></pre>
  
  <p>From looking at where a and b reside in memory I have worked out what is happening. The string copied to b is not null terminated. This is causing the contents of a to be removed because b is located (0028FF20) before a in memory (0028FF30).</p>
  
  <p>What is happening? Does strcpy(b,"string") not stop until it has gone through all the memory on the stack frame variables? Sorry if I am not using the correct terminology. :)</p>