Changeset 4917:28d251acb8ca in roaraudio


Ignore:
Timestamp:
05/07/11 22:02:33 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

replaced sprintf() with snprintf() call

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/env.c

    r4708 r4917  
    4040 return setenv(keyval->key, keyval->value, 1); 
    4141#elif defined(ROAR_HAVE_PUTENV) 
     42 size_t len; 
    4243 char * str; 
    4344 
     45 len = trlen(keyval->key) + strlen(keyval->value) + 2; 
     46 
    4447 // TODO: does this leak memory? 
    45  if ( (str = malloc(strlen(keyval->key) + strlen(keyval->value) + 2)) == NULL ) { 
     48 if ( (str = malloc(len)) == NULL ) { 
    4649  return -1; 
    4750 } 
    4851 
    49  sprintf(str, "%s=%s", keyval->key, keyval->value); 
     52 snprintf(str, len, "%s=%s", keyval->key, keyval->value); 
    5053 
    5154 return putenv(str) == 0 ? 0 : -1; 
Note: See TracChangeset for help on using the changeset viewer.