0

Any suggestions on the work around / alternative appreciated. I am trying to overwrite nulls before returning to calling function. Print statements included.

else if (DB_SPC.option == OSTMP3)
{                                  /* overwrite nulls                  */

  printf("\n value of tmp_buf = %s\n", tmp_buf);

  printf("\n before OSTMP3 Strncpy \n");

  strncpy(tmp_buf+8,tmp_buf+9,6);

  printf("\n after OSTMP3 Strncpy and before strcpy \n");

  strcpy(tmp_buf+14,tmp_buf+16);

  printf("\n after OSTMP3 strcpy \n");

}
value of tmp_buf = 19990101
before OSTMP3 Strncpy 
Abort trap: 6
Rachid K.
  • 4,490
  • 3
  • 11
  • 30

1 Answers1

1

The manual of strcpy() specifies that the source and destination buffers should not overlap:

The strcpy() function copies the string pointed to by src, including the terminating null byte ('\0'), to the buffer pointed to by dest. The strings may not overlap, and the destination string dest must be large enough to receive the copy. Beware of buffer overruns! (See BUGS.)

Rachid K.
  • 4,490
  • 3
  • 11
  • 30