buff = (char *)calloc(2048, sizeof(char));
buff = (char *)malloc(2048);
addgroup_main(int argn, char *argv[]){	int val;	gid_t gid;	int have_gid = FALSE, have_members = FALSE, have_threshold = FALSE;	int be_verbose = FALSE;	int temp_members, members;	tcfsgpwdb **group_info;	/*	 * Going to check the arguments	 */	while ((val = getopt(argn, argv, "vg:m:t:h")) != EOF)		switch (val) {		case 'm':			members = atoi(optarg);			have_members = TRUE;			break;		case 'g':			gid = (gid_t)atoi(optarg);			if (!gid && optarg[0] != '0') { /* group name given */				struct group *group_id;				group_id = getgrnam(optarg);				if (!group_id)					tcfs_error(ER_CUSTOM,						"Nonexistent group.");				gid = group_id->gr_gid;			}			have_gid = TRUE;			break;		case 't':			threshold = atoi(optarg);			have_threshold = TRUE;			break;		case 'h':			printf(addgroup_usage, argv[0]);			exit(OK);		case 'v':			be_verbose = TRUE;			break;		default:			fprintf(stderr,			    "Try %s --help for more information.\n", argv[0]);			exit(ER_UNKOPT);		}	if (argn-optind)		tcfs_error(ER_UNKOPT, NULL);	if (!have_gid) {		char *buff = NULL;		int len;		buff = (char *)calloc(2048, sizeof(char));		if (!buff)			tcfs_error(ER_MEM, NULL);		printf("Group ID (or name) of TCFS group to add to the database: ");		fgets(buff, 2048, stdin);		len = strlen(buff) - 1;		buff[len] = buff[len] == '\n' ? 0 : buff[len];		gid = atoi(buff);		if (!gid && buff[0] != '0') { /* group name given */ 			struct group *group_id;			group_id = getgrnam(buff);			if (!group_id)				tcfs_error(ER_CUSTOM, "Nonexistent group.");			gid = group_id->gr_gid;		}		if (gid <= 0)			tcfs_error(ER_CUSTOM, "A positive ID please!");		free(buff);	}	if (!have_members) {		char *buff = NULL;		int len;		buff = (char *)calloc(2048, sizeof(char));		if (!buff)			tcfs_error(ER_MEM, NULL);		printf("Number of members for the TCFS group ID #%d: ", gid);		fgets(buff, 2048, stdin);		len = strlen(buff) - 1;		buff[len] = buff[len] == '\n' ? 0 : buff[len];		members = atoi(buff);		free(buff);	}	if (!have_threshold) {		char *buff = NULL;		int len;		buff = (char *)calloc(2048, sizeof(char));		if (!buff)			tcfs_error(ER_MEM, NULL);		printf("Threshold for the TCFS group ID #%d: ", gid);		fgets(buff, 2048, stdin);		len = strlen(buff) - 1;		buff[len] = buff[len] == '\n' ? 0 : buff[len];		threshold = atoi(buff);		free(buff);	}	if (members < 2)		tcfs_error(ER_CUSTOM, "At least two members!");	if (threshold > members || threshold <= 0)		tcfs_error(ER_CUSTOM, "The threshold must be no greater than the number of members and greater than zero!");	S = gentcfskey();#ifdef DEBUG_TCFS	{		int i;		printf("La chiave segreta e':\n");		for (i = 0; i < KEYSIZE; i++)			printf("%u:", S[i]);		printf("\n");	}#endif	gencoeff();	temp_members = members;	group_info = (tcfsgpwdb **)calloc(members, sizeof(tcfsgpwdb *));	/*	 * Creating user entry	 */	while (members) {		char *user = NULL, *passwd = NULL;		unsigned char *newkey = NULL, *cryptedkey = NULL;		tcfsgpwdb *tmp = NULL;		int tmpmemb = temp_members, cont = 0;		group_info[members - 1] = (tcfsgpwdb *)calloc(1,		    sizeof(tcfsgpwdb));		group_info[members - 1]->gid = gid;		group_info[members - 1]->n = members;		group_info[members - 1]->soglia = threshold;		if (!unix_auth(&user, &passwd, FALSE)) {			fprintf(stderr, "Invalid password or the user does not exist.\n");			continue;		}		if (tcfs_ggetpwnam(user, gid, &tmp))			tcfs_error(ER_CUSTOM, "Group already exists.");		while (tmpmemb > members) {			if (!strcmp(user, group_info[tmpmemb-1]->user)) {				fprintf(stderr, "User already present into the group.\n");				cont = 1;				break;			}			tmpmemb--;		}		if (cont)			continue;		strcpy(group_info[members - 1]->user, user);		newkey = (unsigned char *)calloc(GKEYSIZE + 1, sizeof(char));		if (!newkey)			tcfs_error(ER_MEM, NULL);		cryptedkey = (unsigned char *)calloc(UUGKEYSIZE, sizeof(char));		if (!cryptedkey)			tcfs_error(ER_MEM, NULL);		memcpy(newkey, gengrpkey(user), GKEYSIZE);		newkey[GKEYSIZE] = '\0';		/*		 * Encrypt the just generated key with the user password		 */		if (!tcfs_encrypt_key(passwd, newkey, GKEYSIZE, cryptedkey,		    UUGKEYSIZE))			tcfs_error(ER_MEM, NULL);		free(newkey);		strlcpy(group_info[members - 1]->gkey, cryptedkey,		    GKEYSIZE + 1);		free(cryptedkey);		members--;	}	members = temp_members;	while (members) {		if (be_verbose)			printf("Creating a new entry for group %d and user %s in the TCFS database...\n", 				group_info[members - 1]->gid,				group_info[members - 1]->user);		if (!tcfs_gputpwnam(group_info[members - 1]->user,				     group_info[members - 1], U_NEW)) {				/* TODO: Remove the group entries saved before */			tcfs_error(ER_CUSTOM, "Error: cannot add a user to the group.");		}		if (be_verbose)			printf("TCFS group entry for user %s created.\n", group_info[members - 1]->user);		members--;	}	tcfs_error(ER_CUSTOM, "\nAll group keys generated.");	return (0);}