Changeset 1d94116


Ignore:
Timestamp:
Feb 4, 2020, 2:00:42 PM (20 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
e3fea42
Parents:
e56eb455
Message:

do not allow a NULL printf-format to abort

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/interpose.cfa

    re56eb455 r1d94116  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 30 17:47:32 2020
    13 // Update Count     : 156
     12// Last Modified On : Tue Feb  4 11:38:20 2020
     13// Update Count     : 161
    1414//
    1515
     
    2929#include "bits/signal.hfa"                                                              // sigHandler_?
    3030#include "startup.hfa"                                                                  // STARTUP_PRIORITY_CORE
     31#include <assert.h>
    3132
    3233//=============================================================================================
     
    4041
    4142typedef void (* generic_fptr_t)(void);
    42 generic_fptr_t interpose_symbol( const char * symbol, const char * version ) {
     43generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) {
    4344        const char * error;
    4445
     
    145146extern "C" {
    146147        void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    147                 abort( false, NULL ); // FIX ME: 0p does not work
     148                abort( false, "%s", "" );
    148149        }
    149150
     
    161162
    162163void * kernel_abort( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 0p; }
    163 void kernel_abort_msg( void * data, char * buffer, int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
     164void kernel_abort_msg( void * data, char buffer[], int size ) __attribute__(( __nothrow__, __leaf__, __weak__ )) {}
    164165// See concurrency/kernel.cfa for strong definition used in multi-processor mode.
    165166int kernel_abort_lastframe( void ) __attribute__(( __nothrow__, __leaf__, __weak__ )) { return 4; }
     
    228229        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    229230
    230         if ( fmt ) {
    231                 va_list args;
    232                 va_start( args, fmt );
    233 
    234                 len = vsnprintf( abort_text, abort_text_size, fmt, args );
    235                 va_end( args );
    236                 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
    237 
    238                 if ( fmt[strlen( fmt ) - 1] != '\n' ) {                 // add optional newline if missing at the end of the format text
    239                         __cfaabi_dbg_write( "\n", 1 );
    240                 }
     231        assert( fmt );
     232        va_list args;
     233        va_start( args, fmt );
     234
     235        len = vsnprintf( abort_text, abort_text_size, fmt, args );
     236        va_end( args );
     237        __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     238
     239        if ( fmt[strlen( fmt ) - 1] != '\n' ) {                 // add optional newline if missing at the end of the format text
     240                __cfaabi_dbg_write( "\n", 1 );
    241241        }
    242242
Note: See TracChangeset for help on using the changeset viewer.