=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rsync/flist.c,v retrieving revision 1.27 retrieving revision 1.28 diff -c -r1.27 -r1.28 *** src/usr.bin/rsync/flist.c 2019/06/02 14:29:58 1.27 --- src/usr.bin/rsync/flist.c 2019/06/23 10:28:32 1.28 *************** *** 1,4 **** ! /* $Id: flist.c,v 1.27 2019/06/02 14:29:58 deraadt Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * Copyright (c) 2019 Florian Obser --- 1,4 ---- ! /* $Id: flist.c,v 1.28 2019/06/23 10:28:32 benno Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * Copyright (c) 2019 Florian Obser *************** *** 803,814 **** size_t *max) { char *cargv[2], *cp; ! int rc = 0, nxdev = 0, flag, i; FTS *fts; FTSENT *ent; struct flist *f; ! size_t flsz = 0, stripdir; ! dev_t *xdev; struct stat st; cargv[0] = root; --- 803,814 ---- size_t *max) { char *cargv[2], *cp; ! int rc = 0, flag; FTS *fts; FTSENT *ent; struct flist *f; ! size_t i, flsz = 0, nxdev = 0, stripdir; ! dev_t *newxdev, *xdev = NULL; struct stat st; cargv[0] = root; *************** *** 931,941 **** !S_ISDIR(ent->fts_statp->st_mode)) continue; - if ((xdev = malloc(sizeof(dev_t))) == NULL) { - ERRX1("malloc"); - goto out; - } - flag = 0; for (i = 0; i < nxdev; i++) if (xdev[i] == ent->fts_statp->st_dev) { --- 931,936 ---- *************** *** 945,956 **** if (flag) continue; ! if (nxdev) ! if ((xdev = realloc(xdev, sizeof(dev_t))) == ! NULL) { ! ERRX1("realloc"); ! goto out; ! } xdev[nxdev] = ent->fts_statp->st_dev; nxdev++; } --- 940,951 ---- if (flag) continue; ! if ((newxdev = reallocarray(xdev, nxdev + 1, ! sizeof(dev_t))) == NULL) { ! ERRX1("reallocarray"); ! goto out; ! } ! xdev = newxdev; xdev[nxdev] = ent->fts_statp->st_dev; nxdev++; } *************** *** 1008,1015 **** rc = 1; out: fts_close(fts); ! if (sess->opts->one_file_system) ! free(xdev); return rc; } --- 1003,1009 ---- rc = 1; out: fts_close(fts); ! free(xdev); return rc; }