diff options
author | deraadt@openbsd.org <deraadt@openbsd.org> | 2017-05-31 09:15:42 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-06-01 14:55:22 +1000 |
commit | 9e509d4ec97cb3d71696f1a2f1fdad254cbbce11 (patch) | |
tree | 8f33ae8fa9bcfa0d9c80d0e0f1555a814a844bc1 /scp.c | |
parent | dc5dc45662773c0f7745c29cf77ae2d52723e55e (diff) |
upstream commit
Switch to recallocarray() for a few operations. Both
growth and shrinkage are handled safely, and there also is no need for
preallocation dances. Future changes in this area will be less error prone.
Review and one bug found by markus
Upstream-ID: 822d664d6a5a1d10eccb23acdd53578a679d5065
Diffstat (limited to 'scp.c')
-rw-r--r-- | scp.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: scp.c,v 1.191 2017/05/02 08:06:33 jmc Exp $ */ | 1 | /* $OpenBSD: scp.c,v 1.192 2017/05/31 09:15:42 deraadt Exp $ */ |
2 | /* | 2 | /* |
3 | * scp - secure remote copy. This is basically patched BSD rcp which | 3 | * scp - secure remote copy. This is basically patched BSD rcp which |
4 | * uses ssh to do the data transfer (instead of using rcmd). | 4 | * uses ssh to do the data transfer (instead of using rcmd). |
@@ -1368,11 +1368,7 @@ allocbuf(BUF *bp, int fd, int blksize) | |||
1368 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ | 1368 | #endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */ |
1369 | if (bp->cnt >= size) | 1369 | if (bp->cnt >= size) |
1370 | return (bp); | 1370 | return (bp); |
1371 | if (bp->buf == NULL) | 1371 | bp->buf = xrecallocarray(bp->buf, bp->cnt, size, 1); |
1372 | bp->buf = xmalloc(size); | ||
1373 | else | ||
1374 | bp->buf = xreallocarray(bp->buf, 1, size); | ||
1375 | memset(bp->buf, 0, size); | ||
1376 | bp->cnt = size; | 1372 | bp->cnt = size; |
1377 | return (bp); | 1373 | return (bp); |
1378 | } | 1374 | } |