if (snprintf(filename, len, "%s/%s", queue_dir, ftsent->fts_name) > len)
if (snprintf(filename, len, "%s/%s", queue_dir, ftsent->fts_name) >= len)
main(int argc, char **argv){    char *log_file = NULL;    char *queue_dir = NULL;    char *list[2];    char *buffer, *filename;    int num_to_send = DEFAULT_NUM, piece, fp, len;    FTS *fts;    FTSENT *ftsent;    FILE *sfp;    err_prog_name(argv[0]);    OPTIONS("[-l log] [-n num] queuedir")	NUMBER('n', num_to_send)	STRING('l', log_file)    ENDOPTS;    if (argc != 2)	usage();    queue_dir = argv[1];    list[0] = queue_dir;    list[1] = NULL;    fts = fts_open(list, FTS_PHYSICAL, fts_sort);    if (fts == NULL)    {	err("fts failed on `%s'", queue_dir);	exit(1);    }    (void) fts_read(fts);    ftsent = fts_children(fts, 0);    if (ftsent == NULL)    {	err("ftschildren failed");	exit(1);    }    /* assumption :-( */    len = strlen(queue_dir) + 40;    filename = malloc(len);    if (filename == NULL)    {	err("malloc failed");	exit(1);    }    for (piece = 0; piece < num_to_send ; piece++)    {	/* Skip non-files and files we should ignore (ones starting with `.') */#define ISFILE ((ftsent->fts_info & FTS_F) == FTS_F)#define IGNORE (ftsent->fts_name[0] == '.')#define HASNEXT (ftsent->fts_link != NULL)	while(((!ISFILE) || (IGNORE)) && (HASNEXT))	    ftsent = ftsent->fts_link;	if ((!ISFILE) || (IGNORE))	{	    err("No more chunks to mail");	    exit(0);	}#undef ISFILE#undef IGNORE#undef HASNEXT	if (snprintf(filename, len, "%s/%s", queue_dir, ftsent->fts_name) > len)	    err("snprintf(filename) longer than buffer");	fp = open(filename, O_RDONLY, 0);	if (fp <  0)	{	    err("open(`%s') failed, errno = %d", filename, errno);	    exit(1);	}	buffer = mmap(0, ftsent->fts_statp->st_size, PROT_READ, MAP_PRIVATE, fp, 0);	if (((long) buffer) <= 0)	{	    err("mmap failed, errno = %d", errno);	    exit(1);	}	sfp = open_sendmail();	    	if (sfp == NULL)	    exit(1);		if (fwrite(buffer, ftsent->fts_statp->st_size, 1, sfp) < 1)	{	    err("fwrite failed: errno = %d", errno);	    close_sendmail(sfp);	    exit(1);	}	if (!close_sendmail(sfp))	    exit(1);	munmap(buffer, ftsent->fts_statp->st_size);	close(fp);	if (unlink(filename) < 0)	{	    err("unlink of `%s' failed", filename);	    exit(1);	}		err("sent file `%s'", ftsent->fts_name);	if (ftsent->fts_link != NULL)	    ftsent = ftsent->fts_link;	else	    break;    }    err("exiting normally");    return(0);}