Changeset 5689

Show
Ignore:
Timestamp:
11/04/09 15:22:43 (3 weeks ago)
Author:
jayesh
Message:

Making sure that we don't have the ESCAPE character at the end of a command argument in SMPD. See ticket 915 for details

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • mpich2/trunk/src/pm/smpd/smpd_command.c

    r4502 r5689  
    556556int smpd_add_command_arg(smpd_command_t *cmd_ptr, char *param, char *value) 
    557557{ 
    558     char *str; 
    559     int len; 
     558    char *str=NULL, *tmp_value=NULL; 
     559    int len, value_len; 
    560560    int result; 
    561561    int cmd_length; 
     
    591591    } 
    592592 
     593    /* Check if we have a escape character at the end of the 
     594     * value string 
     595     * If we do, add a separator character to value string 
     596     */ 
     597    value_len = (int )strlen(value); 
     598    tmp_value = NULL; 
     599    if(value[value_len - 1] == MPIU_STR_ESCAPE_CHAR){ 
     600        tmp_value = (char *)MPIU_Malloc(value_len + 2); 
     601        if(tmp_value == NULL){ 
     602            smpd_err_printf("Unable to allocate memory for tmp value string\n"); 
     603            smpd_exit_fn(FCNAME); 
     604            return SMPD_FAIL; 
     605        } 
     606        MPIU_Strncpy(tmp_value, value, value_len + 2); 
     607        tmp_value[value_len] = MPIU_STR_SEPAR_CHAR; 
     608        tmp_value[value_len + 1] = '\0'; 
     609        value = tmp_value; 
     610    } 
     611 
    593612    result = MPIU_Str_add_string_arg(&str, &len, param, value); 
    594613    if (result != MPIU_STR_SUCCESS) 
    595614    { 
    596         smpd_err_printf("unable to add the command parameter: %s=%s\n", param, value); 
    597         smpd_exit_fn(FCNAME); 
    598         return SMPD_FAIL; 
    599     } 
     615        smpd_err_printf("unable to add the command parameter: %s=%s\n", param, value); 
     616        if(tmp_value) MPIU_Free(tmp_value); 
     617        smpd_exit_fn(FCNAME); 
     618        return SMPD_FAIL; 
     619    } 
     620 
     621    if(tmp_value) MPIU_Free(tmp_value); 
    600622    smpd_exit_fn(FCNAME); 
    601623    return SMPD_SUCCESS;