Changeset 1078

Show
Ignore:
Timestamp:
07/19/08 06:08:02 (6 weeks ago)
Author:
stevenhl
Message:

More Fortify infrastructure enhancements
Rework Fortify_SetOwner
Add Fortify_BecomeOwner
Avoid more spurious leak reports

Location:
trunk
Files:
17 modified

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r1077 r1078  
    13611361    else { 
    13621362#     ifdef FORTIFY 
    1363       Fortify_ChangeOwner(dcd); 
     1363      Fortify_BecomeOwner(dcd); 
    13641364#     endif 
    13651365      /* set unique id */ 
  • trunk/dll/autoview.c

    r1063 r1078  
    477477                          (pffbFile->achName[1] == '.' && 
    478478                           !pffbFile->achName[2]))))) { 
    479                     CommaFmtULL(szCmmaFmtFileSize, 
    480                                 sizeof(szCmmaFmtFileSize), 
    481                                 pffbFile->cbFile + CBLIST_TO_EASIZE(pffbFile->cbList), 
    482                                 ' '); 
     479                    CommaFmtULL(szCmmaFmtFileSize, 
     480                                sizeof(szCmmaFmtFileSize), 
     481                                pffbFile->cbFile + CBLIST_TO_EASIZE(pffbFile->cbList), 
     482                                ' '); 
    483483                    sprintf(p, 
    484484                            "%s%-*.*s  %-8s  [%s%s%s%s]  %04lu/%02lu/%02lu " 
     
    487487                            ml, 
    488488                            ml, 
    489                             pffbFile->achName, 
    490                             szCmmaFmtFileSize, 
     489                            pffbFile->achName, 
     490                            szCmmaFmtFileSize, 
    491491                            pffbFile->attrFile & FILE_READONLY ? "R" : "-", 
    492492                            pffbFile->attrFile & FILE_ARCHIVED ? "A" : "-", 
     
    640640#   ifdef FORTIFY 
    641641    Fortify_EnterScope(); 
    642 #    endif 
     642#   endif 
    643643    hmq2 = WinCreateMsgQueue(hab2, 128); 
    644644    if (hmq2) { 
     
    675675#   ifdef FORTIFY 
    676676    Fortify_LeaveScope(); 
    677 #    endif 
     677#   endif 
    678678  } 
    679679} 
     
    800800              free(ea); 
    801801#             ifdef FORTIFY 
    802               Fortify_LeaveScope(); 
     802              Fortify_LeaveScope(); 
    803803#              endif 
    804804            } 
     
    853853            free(cf); 
    854854#           ifdef FORTIFY 
    855             Fortify_LeaveScope(); 
     855            Fortify_LeaveScope(); 
    856856#            endif 
    857857        } 
  • trunk/dll/collect.c

    r1077 r1078  
    513513    if (dcd) { 
    514514#     ifdef FORTIFY 
    515       Fortify_ChangeOwner(dcd); 
     515      Fortify_BecomeOwner(dcd); 
    516516#     endif 
    517517      /* set unique id */ 
     
    703703 
    704704#     ifdef FORTIFY 
    705       Fortify_ChangeOwner(mp1); 
     705      Fortify_BecomeOwner(mp1); 
    706706#     endif 
    707707 
     
    911911    if (mp1) { 
    912912#     ifdef FORTIFY 
    913       Fortify_ChangeOwner(mp1); 
     913      Fortify_BecomeOwner(mp1); 
    914914#     endif 
    915915      dcd = WinQueryWindowPtr(hwnd, QWL_USER); 
     
    948948    if (mp1) { 
    949949#     ifdef FORTIFY 
    950       Fortify_ChangeOwner(mp1); 
     950      Fortify_BecomeOwner(mp1); 
    951951#     endif 
    952952      dcd = WinQueryWindowPtr(hwnd, QWL_USER); 
     
    14961496#     ifdef FORTIFY 
    14971497      Fortify_EnterScope(); 
    1498       Fortify_ChangeOwner(mp1); 
     1498      Fortify_BecomeOwner(mp1); 
    14991499#     endif 
    15001500      if (!dcd) 
  • trunk/dll/command.c

    r1039 r1078  
    2424  29 Feb 08 GKY Changes to enable user settable command line length 
    2525  29 Feb 08 GKY Use xfree where appropriate 
     26  18 Jul 08 SHL Add Fortify support 
    2627 
    2728***********************************************************************/ 
     
    355356        info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__); 
    356357        if (info) { 
     358#         ifdef FORTIFY 
     359          Fortify_SetOwner(info, 1); 
     360          Fortify_SetScope(info, 1); 
     361#         endif 
    357362          info->pszCmdLine = xstrdup(pszCmdLine, pszSrcFile, __LINE__); 
    358363          info->title = xstrdup(title, pszSrcFile, __LINE__); 
     
    364369            break; 
    365370          } 
     371#         ifdef FORTIFY 
     372          Fortify_SetOwner(info->pszCmdLine, 1); 
     373          Fortify_SetScope(info->pszCmdLine, 1); 
     374          Fortify_SetOwner(info->title, 1); 
     375          Fortify_SetScope(info->title, 1); 
     376#         endif 
    366377          if (!cmdhead) 
    367378            cmdhead = info; 
  • trunk/dll/dircnrs.c

    r1077 r1078  
    646646    if (dcd) { 
    647647#     ifdef FORTIFY 
    648       Fortify_ChangeOwner(dcd); 
     648      Fortify_BecomeOwner(dcd);         // We free dcd 
    649649#     endif 
    650650      /* set unique id */ 
     
    10651065 
    10661066  case WM_DESTROY: 
     1067#   ifdef FORTIFY 
     1068    DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p", hwnd);   // 18 Jul 08 SHL fixme 
     1069#   endif 
    10671070    dcd = WinQueryWindowPtr(hwnd, QWL_USER); 
    10681071    if (dcd) { 
     
    10791082#     ifdef FORTIFY 
    10801083      Fortify_LeaveScope(); 
    1081 #      endif 
     1084#     endif 
    10821085      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL); 
    10831086      DosPostEventSem(CompactSem); 
     
    34083411 
    34093412  case WM_DESTROY: 
     3413#   ifdef FORTIFY 
     3414    DbgMsg(pszSrcFile, __LINE__, "WM_DESTROY hwnd %p", hwnd);   // 18 Jul 08 SHL fixme 
     3415#   endif 
    34103416    if (DirMenu) 
    34113417      WinDestroyWindow(DirMenu); 
     
    35423548        } 
    35433549        else { 
     3550#         ifdef FORTIFY 
     3551          Fortify_ChangeScope(dcd, -1); 
     3552#         endif 
    35443553          RestorePresParams(dcd->hwndCnr, "DirCnr"); 
    35453554          WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd); 
  • trunk/dll/filldir.c

    r1077 r1078  
    6363#include "errutil.h"                    // Dos_Error... 
    6464#include "strutil.h"                    // GetPString 
     65#include "misc.h"                       // GetTidForWindow 
     66#include "fortify.h"                    // 06 May 08 SHL 
    6567#include "fm3dll.h" 
    66  
    67 #include "fortify.h"                    // 06 May 08 SHL 
    6868 
    6969static PSZ pszSrcFile = __FILE__; 
     
    262262      c2++; 
    263263    pci->pszFileName = xmalloc(c + c2, pszSrcFile, __LINE__); 
     264#   ifdef FORTIFY 
     265    { 
     266      unsigned tid = GetTidForWindow(hwndCnr); 
     267      // char buf[256]; 
     268      if (tid == 1) 
     269        Fortify_ChangeScope(pci->pszFileName, -1); 
     270      else 
     271        Fortify_SetOwner(pci->pszFileName, 1); 
     272      // sprintf(buf, "Owner forced to %u", GetTidForWindow(hwndCnr)); 
     273      // Fortify_LabelPointer(pci->pszFmtFileSize, buf); 
     274    } 
     275#   endif 
    264276    memcpy(pci->pszFileName, pszDirectory, c + 1); 
    265277    p = pci->pszFileName + c - 1; 
     
    353365          value = pfea->szName + pfea->cbName + 1; 
    354366          value[pfea->cbValue] = 0; 
    355           if (*(USHORT *) value == EAT_ASCII) 
     367          if (*(USHORT *) value == EAT_ASCII) { 
    356368            pci->pszLongName = xstrdup(value + (sizeof(USHORT) * 2), pszSrcFile, __LINE__); 
     369#           ifdef FORTIFY 
     370            { 
     371              unsigned tid = GetTidForWindow(hwndCnr); 
     372              // char buf[256]; 
     373              if (tid == 1) 
     374                Fortify_ChangeScope(pci->pszLongName, -1); 
     375              else 
     376                Fortify_SetOwner(pci->pszLongName, 1); 
     377              // sprintf(buf, "Owner forced to %u", GetTidForWindow(hwndCnr)); 
     378              // Fortify_LabelPointer(pci->pszFmtFileSize, buf); 
     379            } 
     380#           endif 
     381          } 
    357382        } 
    358383        free(pfealist); 
     
    428453  //comma format the file size for large file support 
    429454  { 
    430   CHAR szBuf[30]; 
     455    CHAR szBuf[30]; 
    431456    CommaFmtULL(szBuf, sizeof(szBuf), pffb->cbFile, ' '); 
    432457    pci->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__); 
     458#   ifdef FORTIFY 
     459    { 
     460      unsigned tid = GetTidForWindow(hwndCnr); 
     461      // char buf[256]; 
     462      if (tid == 1) 
     463        Fortify_ChangeScope(pci->pszFmtFileSize, -1); 
     464      else 
     465        Fortify_SetOwner(pci->pszFmtFileSize, 1); 
     466      // sprintf(buf, "Owner forced to %u", GetTidForWindow(hwndCnr)); 
     467      // Fortify_LabelPointer(pci->pszFmtFileSize, buf); 
     468    } 
     469#   endif 
    433470  } 
    434471 
  • trunk/dll/fm3dll.def

    r1057 r1078  
    44 
    55# 14 Jun 07 SHL Convert to OpenWatcom 
     6# 18 Jul 08 SHL Add Runtime_Error 
    67 
    78option description '@#SLAInc:3.11#@##1## 07/08/2008 03:11:00      GKYBuild::EN:US:0:U:@@FM/2 Runtime DLL Copyright (c) 1993, 1998 M. Kimes Copyright (c) 2001, 2008 Steven Levine and Associates, Inc.' 
     
    288289         xDosFindNext_                                .270, 
    289290         xfree_                                       .271, 
    290          xmalloc_                                     .272 
    291  
     291         xmalloc_                                     .272, 
     292         Runtime_Error_                               .273 
     293 
  • trunk/dll/fortify.c

    r1077 r1078  
    22/* $Id$ */ 
    33/* fortify.cxx - A fortified memory allocation shell - V2.2 */ 
     4 /* vim: tabs 4 */ 
    45 
    56/* 
     
    4243 
    4344 /* 06 May 08 SHL Rework scope logic to be MT capable 
    44     26 May 08 SHL Show TID for leaking scope 
    45     17 Jul 08 SHL Add Fortify_SetOwner Fortify_ChangeOwner Fortify_ChangeScope 
    46     18 Jul 08 SHL Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT 
     45        26 May 08 SHL Show TID for leaking scope 
     46        17 Jul 08 SHL Add Fortify_PresetOwner Fortify_BecomeOwner Fortify_ChangeScope 
     47        18 Jul 08 SHL Add FORTIFY_VERBOSE_SCOPE_ENTER_EXIT 
     48        18 Jul 08 SHL Add Fortify_SetScope 
     49        18 Jul 08 SHL Rename Fortify_ChangeOwner to Fortify_BecomeOwner 
     50        18 Jul 08 SHL Add reworked Fortify_SetOwner 
    4751 */ 
    4852 
     
    8993struct Header 
    9094{ 
    91     unsigned short Checksum;    /* For the integrity of our goodies  */ 
    92     const char    *File;        /* The sourcefile of the allocator   */ 
    93     unsigned long  Line;        /* The sourceline of the allocator   */ 
    94 #ifdef FORTIFY_TRACK_DEALLOCATED_MEMORY 
    95     const char    *FreedFile;   /* The sourcefile of the deallocator */ 
    96     unsigned long  FreedLine;   /* The sourceline of the deallocator */ 
    97     unsigned char  Deallocator; /* The deallocator used              */ 
    98 #endif 
    99     size_t         Size;        /* The size of the malloc'd block    */ 
    100     struct Header *Prev;        /* Previous link                     */ 
    101     struct Header *Next;        /* Next link                         */ 
    102     char          *Label;       /* User's Label (may be null)        */ 
    103     unsigned char  Scope;       /* Scope level of the owner          */ 
    104     unsigned char  Allocator;   /* malloc/realloc/new/etc            */ 
    105 #   ifdef MT_SCOPES 
    106     unsigned short Owner;       /* TID ordinal of block owner        */ 
    107 #   endif 
     95        unsigned short Checksum;    /* For the integrity of our goodies  */ 
     96        const char    *File;        /* The sourcefile of the allocator   */ 
     97        unsigned long  Line;        /* The sourceline of the allocator   */ 
     98#       ifdef FORTIFY_TRACK_DEALLOCATED_MEMORY 
     99        const char    *FreedFile;   /* The sourcefile of the deallocator */ 
     100        unsigned long  FreedLine;   /* The sourceline of the deallocator */ 
     101        unsigned char  Deallocator; /* The deallocator used              */ 
     102#       endif 
     103        size_t         Size;        /* The size of the malloc'd block    */ 
     104        struct Header *Prev;        /* Previous link                     */ 
     105        struct Header *Next;        /* Next link                         */ 
     106        char          *Label;   /* User's Label (may be null)        */ 
     107        unsigned char  Scope;       /* Scope level of the owner          */ 
     108        unsigned char  Allocator;   /* malloc/realloc/new/etc            */ 
     109#       ifdef MT_SCOPES 
     110        unsigned short Owner;       /* TID ordinal of block owner        */ 
     111#       endif 
    108112}; 
    109113 
     
    153157#ifdef FORTIFY_TRACK_DEALLOCATED_MEMORY 
    154158#ifdef FORTIFY_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY 
     159 
    155160#ifdef FORTIFY_VERBOSE_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY 
    156     static const char *st_DeallocatedMemoryBlockString(struct Header *h); 
     161static const char *st_DeallocatedMemoryBlockString(struct Header *h); 
    157162#endif /* FORTIFY_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */ 
     163 
    158164#endif /* FORTIFY_VERBOSE_WARN_WHEN_DISCARDING_DEALLOCATED_MEMORY */ 
    159     static int  st_IsOnDeallocatedList(struct Header *h); 
    160     static int st_PurgeDeallocatedBlocks(unsigned long Bytes, const char *file, unsigned long line); 
    161     static int st_PurgeDeallocatedScope(unsigned char Scope, const char *file, unsigned long line); 
    162     static int st_CheckDeallocatedBlock(struct Header *h, const char *file, unsigned long line); 
    163     static void st_FreeDeallocatedBlock(struct Header *h, const char *file, unsigned long line); 
     165static int  st_IsOnDeallocatedList(struct Header *h); 
     166static int st_PurgeDeallocatedBlocks(unsigned long Bytes, const char *file, unsigned long line); 
     167static int st_PurgeDeallocatedScope(unsigned char Scope, const char *file, unsigned long line); 
     168static int st_CheckDeallocatedBlock(struct Header *h, const char *file, unsigned long line); 
     169static void st_FreeDeallocatedBlock(struct Header *h, const char *file, unsigned long line); 
    164170#endif /* FORTIFY_TRACK_DEALLOCATED_MEMORY */ 
    165171 
     
    176182static const char    *st_LastVerifiedFile = "unknown"; 
    177183static unsigned long  st_LastVerifiedLine; 
     184 
    178185#ifdef MT_SCOPES 
    179186static unsigned volatile st_cOrdinals;          // Number of known threads 
     
    183190static unsigned char  st_Scope            = 0; 
    184191#endif 
     192 
    185193static unsigned char  st_Disabled = 0; 
    186194 
    187195#ifdef __cplusplus 
    188     int FORTIFY_STORAGE                 gbl_FortifyMagic = 0;   // 28 Jan 08 SHL 
    189     static const    char *st_DeleteFile[FORTIFY_DELETE_STACK_SIZE]; 
    190     static unsigned long  st_DeleteLine[FORTIFY_DELETE_STACK_SIZE]; 
    191     static unsigned long  st_DeleteStackTop; 
     196int FORTIFY_STORAGE                 gbl_FortifyMagic = 0;       // 28 Jan 08 SHL 
     197static const    char *st_DeleteFile[FORTIFY_DELETE_STACK_SIZE]; 
     198static unsigned long  st_DeleteLine[FORTIFY_DELETE_STACK_SIZE]; 
     199static unsigned long  st_DeleteStackTop; 
    192200#endif /* __cplusplus */ 
    193201 
     
    203211 
    204212#ifdef FORTIFY_TRACK_DEALLOCATED_MEMORY 
    205     static struct Header *st_DeallocatedHead = 0; 
    206     static struct Header *st_DeallocatedTail = 0; 
    207     static unsigned long  st_TotalDeallocated = 0; 
     213static struct Header *st_DeallocatedHead = 0; 
     214static struct Header *st_DeallocatedTail = 0; 
     215static unsigned long  st_TotalDeallocated = 0; 
    208216#endif 
    209217 
     
    212220static const char *st_AllocatorName[] = 
    213221{ 
    214     "malloc()", 
    215     "calloc()", 
    216     "realloc()", 
    217     "strdup()", 
    218     "new", 
    219     "new[]" 
     222        "malloc()", 
     223        "calloc()", 
     224        "realloc()", 
     225        "strdup()", 
     226        "new", 
     227        "new[]" 
    220228}; 
    221229 
     
    223231static const char *st_DeallocatorName[] = 
    224232{ 
    225     "nobody", 
    226     "free()", 
    227     "realloc()", 
    228     "delete", 
    229     "delete[]" 
     233        "nobody", 
     234        "free()", 
     235        "realloc()", 
     236        "delete", 
     237        "delete[]" 
    230238}; 
    231239 
    232240static const unsigned char st_ValidDeallocator[] = 
    233241{ 
    234     (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
    235     (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
    236     (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
    237     (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
     242        (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
     243        (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
     244        (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
     245        (1<<Fortify_Deallocator_free) | (1<<Fortify_Deallocator_realloc), 
    238246#if defined(FORTIFY_PROVIDE_ARRAY_NEW) && defined(FORTIFY_PROVIDE_ARRAY_DELETE) 
    239     (1<<Fortify_Deallocator_delete), 
    240     (1<<Fortify_Deallocator_array_delete) 
     247        (1<<Fortify_Deallocator_delete), 
     248        (1<<Fortify_Deallocator_array_delete) 
    241249#else 
    242     (1<<Fortify_Deallocator_delete) | (1<<Fortify_Deallocator_array_delete), 
    243     (1<<Fortify_Deallocator_delete) | (1<<Fortify_Deallocator_array_delete) 
     250        (1<<Fortify_Deallocator_delete) | (1<<Fortify_Deallocator_array_delete), 
     251        (1<<Fortify_Deallocator_delete) | (1<<Fortify_Deallocator_array_delete) 
    244252#endif 
    245253}; 
     
    252260Fortify_Allocate(size_t size, unsigned char allocator, const char *file, unsigned long line) 
    253261{ 
    254     unsigned char *ptr; 
    255     struct Header *h; 
    256     int another_try; 
     262        unsigned char *ptr; 
     263        struct Header *h; 
     264        int another_try; 
    257265 
    258266#ifdef MT_SCOPES 
    259     unsigned ordinal; 
     267        unsigned ordinal; 
    260268#endif 
    261269 
    262     /* 
    263     * If Fortify has been disabled, then it's easy 
    264     */ 
    265     if(st_Disabled) 
    266     { 
    267 #ifdef FORTIFY_FAIL_ON_ZERO_MALLOC 
    268         if(size == 0 && (allocator == Fortify_Allocator_new 
    269                       || allocator == Fortify_Allocator_array_new)) 
     270        /* 
     271        * If Fortify has been disabled, then it's easy 
     272        */ 
     273        if(st_Disabled) 
     274        { 
     275#               ifdef FORTIFY_FAIL_ON_ZERO_MALLOC 
     276                if(size == 0 && (allocator == Fortify_Allocator_new 
     277                                  || allocator == Fortify_Allocator_array_new)) 
    270278                { 
    271279                        /* 
    272280                         * A new of zero bytes must succeed, but a malloc of 
    273             * zero bytes probably won't 
    274             */ 
     281                        * zero bytes probably won't 
     282                        */ 
    275283                        return malloc(1); 
    276284                } 
     285#               endif 
     286 
     287                return malloc(size); 
     288        } 
     289 
     290#ifdef FORTIFY_CHECK_ALL_MEMORY_ON_ALLOCATE 
     291        Fortify_CheckAllMemory(file, line); 
    277292#endif 
    278293 
    279         return malloc(size); 
    280     } 
    281  
    282 #ifdef FORTIFY_CHECK_ALL_MEMORY_ON_ALLOCATE 
    283     Fortify_CheckAllMemory(file, line); 
    284 #endif 
    285  
    286     if(st_AllocateFailRate > 0) 
    287     { 
    288         if(rand() % 100 < st_AllocateFailRate) 
    289         { 
    290 #ifdef FORTIFY_WARN_ON_FALSE_FAIL 
    291             sprintf(st_Buffer, 
    292                     "\nFortify: A \"%s\" of %lu bytes \"false failed\" at %s.%lu\n", 
    293                     st_AllocatorName[allocator], (unsigned long)size, file, line); 
    294             st_Output(st_Buffer); 
    295 #endif 
    296             return(0); 
    297         } 
    298     } 
    299  
    300     /* Check to see if this allocation will 
    301      * push us over the artificial limit 
    302      */ 
    303     if(st_CurAllocation + size > st_AllocationLimit) 
    304     { 
    305 #ifdef FORTIFY_WARN_ON_FALSE_FAIL 
    306         sprintf(st_Buffer, 
    307                 "\nFortify: A \"%s\" of %lu bytes \"false failed\" at %s.%lu\n", 
    308                 st_AllocatorName[allocator], (unsigned long)size, file, line); 
    309         st_Output(st_Buffer); 
    310 #endif 
    311         return(0); 
    312     } 
     294        if(st_AllocateFailRate > 0) 
     295        { 
     296                if(rand() % 100 < st_AllocateFailRate) 
     297                { 
     298#                       ifdef FORTIFY_WARN_ON_FALSE_FAIL 
     299                        sprintf(st_Buffer, 
     300                                "\nFortify: A \"%s\" of %lu bytes \"false failed\" at %s.%lu\n", 
     301                                st_AllocatorName[allocator], (unsigned long)size, file, line); 
     302                        st_Output(st_Buffer); 
     303#                       endif 
     304                        return(0); 
     305                } 
     306        } 
     307 
     308        /* Check to see if this allocation will 
     309         * push us over the artificial limit 
     310         */ 
     311        if(st_CurAllocation + size > st_AllocationLimit) 
     312        { 
     313#               ifdef FORTIFY_WARN_ON_FALSE_FAIL 
     314                sprintf(st_Buffer, 
     315                        "\nFortify: A \"%s\" of %lu bytes \"false failed\" at %s.%lu\n", 
     316                        st_AllocatorName[allocator], (unsigned long)size, file, line); 
     317                st_Output(st_Buffer); 
     318#               endif 
     319                return(0); 
     320        } 
    313321 
    314322#ifdef FORTIFY_WARN_ON_ZERO_MALLOC 
    315323        if(size == 0 && (allocator == Fortify_Allocator_malloc || 
    316                     allocator == Fortify_Allocator_calloc || 
    317                     allocator == Fortify_Allocator_realloc )) 
     324                        allocator == Fortify_Allocator_calloc || 
     325                        allocator == Fortify_Allocator_realloc )) 
    318326        { 
    319327                sprintf(st_Buffer, 
    320                 "\nFortify: A \"%s\" of 0 bytes attempted at %s.%lu\n", 
    321                 st_AllocatorName[allocator], file, line); 
    322         st_Output(st_Buffer); 
     328                                "\nFortify: A \"%s\" of 0 bytes attempted at %s.%lu\n", 
     329                                st_AllocatorName[allocator], file, line); 
     330                st_Output(st_Buffer); 
    323331        } 
    324332#endif /* FORTIFY_WARN_ON_ZERO_MALLOC */ 
     
    326334#ifdef FORTIFY_FAIL_ON_ZERO_MALLOC 
    327335        if(size == 0 && (allocator == Fortify_Allocator_malloc || 
    328                     allocator == Fortify_Allocator_calloc || 
    329                     allocator == Fortify_Allocator_realloc )) 
     336                        allocator == Fortify_Allocator_calloc || 
     337                        allocator == Fortify_Allocator_realloc )) 
    330338        { 
    331339#ifdef FORTIFY_WARN_ON_ALLOCATE_FAIL 
    332         sprintf(st_Buffer, "\nFortify: A \"%s\" of %lu bytes failed at %s.%lu\n", 
    333                 st_AllocatorName[allocator], (unsigned long)size, file, line);