45 |
|
#endif |
46 |
|
|
47 |
|
#include "tools.h" |
48 |
+ |
#include "statgrab.h" |
49 |
|
|
50 |
|
#ifdef SOLARIS |
51 |
|
#ifdef HAVE_LIBDEVINFO_H |
91 |
|
mapping_t *map_end_ptr; |
92 |
|
|
93 |
|
if (mapping == NULL){ |
94 |
< |
mapping = malloc(sizeof(mapping_t)); |
94 |
> |
mapping = sg_malloc(sizeof(mapping_t)); |
95 |
|
if (mapping == NULL) return; |
96 |
|
map_ptr = mapping; |
97 |
|
}else{ |
106 |
|
/* We've reached end of list and not found the entry.. So we need to malloc |
107 |
|
* new mapping_t |
108 |
|
*/ |
109 |
< |
map_end_ptr->next = malloc(sizeof(mapping_t)); |
109 |
> |
map_end_ptr->next = sg_malloc(sizeof(mapping_t)); |
110 |
|
if (map_end_ptr->next == NULL) return; |
111 |
|
map_ptr = map_end_ptr->next; |
112 |
|
} |
113 |
|
|
114 |
|
map_ptr->next = NULL; |
115 |
< |
map_ptr->bsd = strdup(bsd); |
116 |
< |
map_ptr->svr = strdup(svr); |
115 |
> |
map_ptr->bsd = NULL; |
116 |
> |
map_ptr->svr = NULL; |
117 |
> |
if (sg_update_string(&map_ptr->bsd, bsd) < 0 |
118 |
> |
|| sg_update_string(&map_ptr->svr, svr) < 0) { |
119 |
> |
return; |
120 |
> |
} |
121 |
|
|
122 |
|
return; |
123 |
|
} |
127 |
|
DIR *dirp; |
128 |
|
struct dirent *dp; |
129 |
|
struct stat stbuf; |
130 |
< |
char *svr_name; |
130 |
> |
char *svr_name = NULL; |
131 |
|
char current_dir[MAXPATHLEN]; |
132 |
|
char file_name[MAXPATHLEN]; |
133 |
|
char temp_name[MAXPATHLEN]; |
154 |
|
x = readlink(dir_dname, file_name, sizeof(file_name)); |
155 |
|
file_name[x] = '\0'; |
156 |
|
if (strcmp(file_name, temp_name) == 0) { |
157 |
< |
svr_name = strdup(dp->d_name); |
157 |
> |
if (sg_update_string(&svr_name, |
158 |
> |
dp->d_name) < 0) { |
159 |
> |
return NULL; |
160 |
> |
} |
161 |
|
closedir(dirp); |
162 |
|
return svr_name; |
163 |
|
} |
283 |
|
|
284 |
|
char *sg_get_string_match(char *line, regmatch_t *match){ |
285 |
|
int len=match->rm_eo - match->rm_so; |
286 |
< |
char *match_string=malloc(len+1); |
286 |
> |
char *match_string=sg_malloc(len+1); |
287 |
|
|
288 |
|
match_string=strncpy(match_string, line+match->rm_so, len); |
289 |
|
match_string[len]='\0'; |
421 |
|
return 0; |
422 |
|
} |
423 |
|
|
424 |
< |
new = realloc(*dest, strlen(src) + 1); |
424 |
> |
new = sg_realloc(*dest, strlen(src) + 1); |
425 |
|
if (new == NULL) { |
426 |
|
return -1; |
427 |
|
} |
509 |
|
if (setegid(getgid()) != 0) return -1; |
510 |
|
if (seteuid(getuid()) != 0) return -1; |
511 |
|
return 0; |
512 |
+ |
} |
513 |
+ |
|
514 |
+ |
void *sg_realloc(void *ptr, size_t size) { |
515 |
+ |
void *tmp = NULL; |
516 |
+ |
tmp = realloc(ptr, size); |
517 |
+ |
if(tmp == NULL) { |
518 |
+ |
sg_set_error(SG_ERROR_MALLOC_FAILED, NULL); |
519 |
+ |
} |
520 |
+ |
return tmp; |
521 |
|
} |
522 |
|
|