ICU-20171 Fix buffer overrun in genccode

This commit is contained in:
Don 2018-09-24 16:37:13 -07:00 committed by Shane F. Carr
parent db94f46377
commit de6607c9cd

View file

@ -309,16 +309,11 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr
T_FileStream_writeLine(out, assemblyHeader[assemblyHeaderIndex].beginLine);
for(;;) {
memset(buffer, 0, sizeof(buffer));
length=T_FileStream_read(in, buffer, sizeof(buffer));
if(length==0) {
break;
}
if (length != sizeof(buffer)) {
/* pad with extra 0's when at the end of the file */
for(i=0; i < (length % sizeof(uint32_t)); ++i) {
buffer[length+i] = 0;
}
}
for(i=0; i<(length/sizeof(buffer[0])); i++) {
column = write32(out, buffer[i], column);
}