Author Topic: BCX_TmpStrSize  (Read 127 times)

Robert

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
BCX_TmpStrSize
« on: May 11, 2020, 01:06:02 AM »
In BCX 7.4.6, in the $TURBO flag section, the BCX_TmpStrSize array was changed from 512 to 2048.

If I recall correctly, the $TURBO directive was implemented because of complants that allotting 512 temporary string buffers to be used by BCX_TmpStr was excessive.

If this change was intentional, and not collateral damage from the, in my opinion, misguided, effort to protect Noobie Suzy Coder from the trauma of buffer overflow, then I will change the Help file accordingly and modify the expressed default from 512 to 2048.


MrBcx

  • Administrator
  • Sr. Member
  • *****
  • Posts: 284
    • View Profile
Re: BCX_TmpStrSize
« Reply #1 on: May 11, 2020, 08:40:44 AM »
In BCX 7.4.6, in the $TURBO flag section, the BCX_TmpStrSize array was changed from 512 to 2048.

If I recall correctly, the $TURBO directive was implemented because of complants that allotting 512 temporary string buffers to be used by BCX_TmpStr was excessive.

If this change was intentional, and not collateral damage from the, in my opinion, misguided, effort to protect Noobie Suzy Coder from the trauma of buffer overflow, then I will change the Help file accordingly and modify the expressed default from 512 to 2048.

Robert,

The change was intentional.   The change for devotees of the $TURBO directive now explicitly
requires their desired dynamic string buffer size to be stated in their source code.

If a 512 byte temporary string buffer is desired, then typing $TURBO 512 gets the job done.
« Last Edit: May 11, 2020, 08:42:30 AM by MrBcx »

Robert

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
Re: BCX_TmpStrSize
« Reply #2 on: May 11, 2020, 10:19:41 AM »
In BCX 7.4.6, in the $TURBO flag section, the BCX_TmpStrSize array was changed from 512 to 2048.

If I recall correctly, the $TURBO directive was implemented because of complants that allotting 512 temporary string buffers to be used by BCX_TmpStr was excessive.

If this change was intentional, and not collateral damage from the, in my opinion, misguided, effort to protect Noobie Suzy Coder from the trauma of buffer overflow, then I will change the Help file accordingly and modify the expressed default from 512 to 2048.

Robert,

The change was intentional.   The change for devotees of the $TURBO directive now explicitly
requires their desired dynamic string buffer size to be stated in their source code.

If a 512 byte temporary string buffer is desired, then typing $TURBO 512 gets the job done.

MrBCX:

My understanding of your construction of the BCXTmpStr function circular buffers is, as stated in the Help file, that $TURBO changes the default size of the array holding the circular buffers used for temporary storage. It does not allocate a number of bytes for a temporary string buffer.

Code: [Select]
  IF UseFlag THEN
    IF Use_Library THEN FPRINT FP_WRITE, "// BCXRTLIB: BCX_TmpStr"
    CALL Emit_BCX_TmpStrSize(FP_WRITE)
    FPRINT FP_WRITE, "char *BCX_TmpStr (size_t Bites,size_t  iPad,int iAlloc)"
    FPRINT FP_WRITE, "{"
    FPRINT FP_WRITE, "  static int   StrCnt;"
    FPRINT FP_WRITE, "  static char *StrFunc[BCXTmpStrSize];"
    FPRINT FP_WRITE, "  StrCnt=(StrCnt + 1) & (BCXTmpStrSize-1);"
    FPRINT FP_WRITE, "  if(StrFunc[StrCnt]) {free (StrFunc[StrCnt]); StrFunc[StrCnt] = NULL;}"
    FPRINT FP_WRITE, "#if defined BCX_MAX_VAR_SIZE"
    FPRINT FP_WRITE, "  if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)"
    FPRINT FP_WRITE, "  {"
    FPRINT FP_WRITE, "  printf(",ENC$("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\\n"),",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);"
    FPRINT FP_WRITE, "  abort();"
    FPRINT FP_WRITE, "  }"
    FPRINT FP_WRITE, "#endif"
    FPRINT FP_WRITE, "  if(iAlloc) StrFunc[StrCnt]=(char*)calloc(Bites+iPad,sizeof(char));"
    FPRINT FP_WRITE, "  return StrFunc[StrCnt];"
    FPRINT FP_WRITE, sENDBCXRTLIB$
  END IF

Wayne Halsdorf

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: BCX_TmpStrSize
« Reply #3 on: May 11, 2020, 11:23:20 AM »
BCXTmpStrSize would be clearer as to what it does if named BCXTmpStrCircularSize