Skip to content

Commit 283b3ce

Browse files
committed
CBL_COPY_FILE利用時の不正なメモリ参照
* CBL_COPY_FILE関数内で、free済みの領域を利用してファイルのReadを行っていたものを修正 * READ/WRITEのバッファサイズをsizeof(char*)でとっていたため、4 or 8byteでファイルの読み書きをしていた点も修正
1 parent 38331ec commit 283b3ce

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

libcob/fileio.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5119,6 +5119,7 @@ CBL_COPY_FILE (unsigned char *fname1, unsigned char *fname2)
51195119
{
51205120
char *fn1;
51215121
char *fn2;
5122+
char buf[COB_SMALL_BUFF];
51225123
int flag = O_BINARY;
51235124
int ret;
51245125
int i;
@@ -5154,8 +5155,8 @@ CBL_COPY_FILE (unsigned char *fname1, unsigned char *fname2)
51545155
}
51555156
free (fn2);
51565157
ret = 0;
5157-
while ((i = read (fd1, fn1, sizeof(fn1))) > 0) {
5158-
if (write (fd2, fn1, (size_t)i) < 0) {
5158+
while ((i = read (fd1, buf, sizeof(buf))) > 0) {
5159+
if (write (fd2, buf, (size_t)i) < 0) {
51595160
ret = -1;
51605161
break;
51615162
}

0 commit comments

Comments
 (0)