pwent = getpwnam(username);
- if( (tmp = (char *)malloc(strlen(pwent->pw_gecos) +1)) == NULL)
+ if((tmp = strdup(pwent->pw_gecos)) == NULL)
return strdup(username);
rtn = sscanf(pwent->pw_gecos, "%[^,]", tmp);
while( ! ISSPACE(*ptr) )
ptr++;
- if( (*alias = (char *)malloc(ptr-tmp+1)) == NULL) {
+ if( (*alias = (char *)malloc(ptr - tmp)) == NULL) {
free(line);
return 1;
}
- strncpy(*alias, tmp, ptr-tmp);
+ strncpy(*alias, tmp, ptr - tmp - 1);
*(*alias + (ptr - tmp)) = 0;
- while( ISSPACE(*ptr) )
+ while(ISSPACE(*ptr))
ptr++;
*rest = strdup(ptr);
{
char *buf, *p;
int tlen;
+ size_t bufsize, t;
tlen = strlen( type );
- if (( buf = (char *)malloc( LDIF_SIZE_NEEDED( tlen, vlen ) + 1 )) !=
- NULL ) {
+
+ t = LDIF_SIZE_NEEDED( tlen, vlen );
+ if((bufsize = t + 1) <= t)
+ return NULL;
+
+ if (( buf = (char *)malloc( bufsize )) == NULL ) {
+ return NULL;
}
p = buf;
char*
strconcat (const char *str, ...)
{
- int l;
+ unsigned long l;
MY_VA_LOCAL_DECL;
char *s, *concat;
#else
malloc(l);
#endif
+ if(concat == NULL)
+ return NULL;
strcpy (concat, str);
MY_VA_START(str);
if( (dir = (char *)malloc(size)) == NULL)
return NULL;
+
+ *dir = 0;
while( getcwd(dir, size) == NULL && errno == ERANGE )
if( (dir = (char *)realloc(dir, size *=2)) == NULL)