Changeset 11865


Ignore:
Timestamp:
Feb 9, 2011, 6:10:01 AM (11 years ago)
Author:
jordan
Message:

(trunk) improvement to r11864

Since the contents of getcwd() are undefined on error, explicitly terminate the buffer string if getcwd() fails.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r11864 r11865  
    492492    char * result;
    493493    char buf[2048];
    494     *buf = '\0';
    495494#ifdef WIN32
    496495    result = _getcwd( buf, sizeof( buf ) );
     
    499498#endif
    500499    if( result == NULL )
     500    {
    501501        fprintf( stderr, "getcwd error: \"%s\"", tr_strerror( errno ) );
     502        *buf = '\0';
     503    }
    502504    return tr_strdup( buf );
    503505}
  • trunk/utils/create.c

    r11864 r11865  
    8181    char * result;
    8282    char buf[2048];
    83     *buf = '\0';
    8483#ifdef WIN32
    8584    result = _getcwd( buf, sizeof( buf ) );
     
    8786    result = getcwd( buf, sizeof( buf ) );
    8887#endif
    89     if( result == NULL )
     88    if( result == NULL )
     89    {
    9090        fprintf( stderr, "getcwd error: \"%s\"", tr_strerror( errno ) );
     91        *buf = '\0';
     92    }
    9193    return tr_strdup( buf );
    9294}
Note: See TracChangeset for help on using the changeset viewer.