* samba/lib/charcnv.c (unix2dos_format): Fix possible buffer overflow.

(dos2unix_format): Likewise.
This commit is contained in:
Andrew V. Samoilov 2001-08-06 15:37:28 +00:00
parent 2e4e496c36
commit 0ec69ba605
1 changed files with 4 additions and 2 deletions

View File

@ -184,7 +184,8 @@ char *unix2dos_format(char *str,BOOL overwrite)
for (p = str; *p; p++) *p = unix2dos[(unsigned char)*p];
return str;
} else {
for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = unix2dos[(unsigned char)*p];
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof(cvtbuf) - 1]); p++,dp++)
*dp = unix2dos[(unsigned char)*p];
*dp = 0;
return cvtbuf;
}
@ -204,7 +205,8 @@ char *dos2unix_format(char *str, BOOL overwrite)
for (p = str; *p; p++) *p = dos2unix[(unsigned char)*p];
return str;
} else {
for (p = str, dp = cvtbuf; *p; p++,dp++) *dp = dos2unix[(unsigned char)*p];
for (p = str, dp = cvtbuf; *p && dp < &(cvtbuf[sizeof(cvtbuf) - 1]); p++,dp++)
*dp = dos2unix[(unsigned char)*p];
*dp = 0;
return cvtbuf;
}