Changeset 3610 in MondoRescue for branches/3.2/mondo/src/common/libmondo-fork.c
- Timestamp:
- Nov 5, 2016, 6:12:23 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mondo/src/common/libmondo-fork.c
r3604 r3610 35 35 * @param call The program to run. 36 36 * @return The last line of its output. 37 * @note The returned value points to static storage that will be overwritten with each call. 37 * @note The returned value points to storage that needs to be freed by the 38 * caller 38 39 */ 39 40 char *call_program_and_get_last_line_of_output(char *call) 40 41 { 41 42 /*@ buffers ***************************************************** */ 42 static char result[MAX_STR_LEN];43 char *result = NULL; 43 44 char *tmp = NULL; 44 45 … … 46 47 FILE *fin = NULL; 47 48 char *eng_call = NULL; 48 49 /*@ initialize data ********************************************* */50 result[0] = '\0';51 49 52 50 /*@******************************************************************** */ … … 57 55 if ((fin = popen(eng_call, "r"))) { 58 56 while (!feof(fin)) { 59 mr_ getline(tmp, fin);60 if (strlen(tmp) > 1) {61 strcpy(result, tmp);57 mr_free(result); 58 mr_getline(result, fin); 59 if (strlen(result) > 1) { 62 60 log_msg(7, "result = '%s'", result); 63 61 } 64 mr_free(tmp);65 62 } 66 63 paranoid_pclose(fin); … … 69 66 } 70 67 mr_free(eng_call); 71 strip_spaces(result);68 mr_strip_spaces(result); 72 69 log_msg(5, "cpaglloo returns '%s'", result); 73 70 return(result);
Note:
See TracChangeset
for help on using the changeset viewer.