diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/convbdf.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c index 5cd45d0583..cbb13cb34a 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c | |||
@@ -725,8 +725,9 @@ bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2) | |||
725 | * Doing it this way keeps fonts in standard formats, | 725 | * Doing it this way keeps fonts in standard formats, |
726 | * as well as keeping Rockbox hw bitmap format. | 726 | * as well as keeping Rockbox hw bitmap format. |
727 | */ | 727 | */ |
728 | int rotleft(unsigned char *dst, bitmap_t *src, unsigned int width, | 728 | int rotleft(unsigned char *dst, /* output buffer */ |
729 | unsigned int height) | 729 | size_t dstlen, /* buffer size */ |
730 | bitmap_t *src, unsigned int width, unsigned int height) | ||
730 | { | 731 | { |
731 | unsigned int i,j; | 732 | unsigned int i,j; |
732 | unsigned int src_words; /* # words of input image*/ | 733 | unsigned int src_words; /* # words of input image*/ |
@@ -736,6 +737,13 @@ int rotleft(unsigned char *dst, bitmap_t *src, unsigned int width, | |||
736 | /* calc words of input image*/ | 737 | /* calc words of input image*/ |
737 | src_words = BITMAP_WORDS(width) * height; | 738 | src_words = BITMAP_WORDS(width) * height; |
738 | 739 | ||
740 | if(((height + 7) / 8) * width > dstlen) { | ||
741 | fprintf(stderr, "%s:%d %d x %d overflows %d bytes buffer, needs %d\n", | ||
742 | __FILE__, __LINE__, width, height, dstlen, | ||
743 | ((height + 7) / 8) * width ); | ||
744 | return 0; | ||
745 | } | ||
746 | |||
739 | /* clear background*/ | 747 | /* clear background*/ |
740 | memset(dst, 0, ((height + 7) / 8) * width); | 748 | memset(dst, 0, ((height + 7) / 8) * width); |
741 | 749 | ||
@@ -881,10 +889,11 @@ int gen_c_source(struct font* pf, char *path) | |||
881 | bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); | 889 | bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); |
882 | #ifdef ROTATE /* pre-rotated into Rockbox bitmap format */ | 890 | #ifdef ROTATE /* pre-rotated into Rockbox bitmap format */ |
883 | { | 891 | { |
884 | unsigned char bytemap[256]; | 892 | unsigned char bytemap[512]; |
885 | int y8, ix=0; | 893 | int y8, ix=0; |
886 | 894 | ||
887 | int size = rotleft(bytemap, bits, width, pf->height); | 895 | int size = rotleft(bytemap, sizeof(bytemap), bits, width, |
896 | pf->height); | ||
888 | for (y8=0; y8<pf->height; y8+=8) /* column rows */ | 897 | for (y8=0; y8<pf->height; y8+=8) /* column rows */ |
889 | { | 898 | { |
890 | for (x=0; x<width; x++) { | 899 | for (x=0; x<width; x++) { |
@@ -1117,7 +1126,7 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1117 | bitmap_t* bits; | 1126 | bitmap_t* bits; |
1118 | int width = pf->width ? pf->width[i] : pf->maxwidth; | 1127 | int width = pf->width ? pf->width[i] : pf->maxwidth; |
1119 | int size; | 1128 | int size; |
1120 | unsigned char bytemap[256]; | 1129 | unsigned char bytemap[512]; |
1121 | 1130 | ||
1122 | /* Skip missing glyphs */ | 1131 | /* Skip missing glyphs */ |
1123 | if (pf->offset && (pf->offset[i] == (unsigned int)-1)) | 1132 | if (pf->offset && (pf->offset[i] == (unsigned int)-1)) |
@@ -1125,7 +1134,7 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1125 | 1134 | ||
1126 | bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); | 1135 | bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); |
1127 | 1136 | ||
1128 | size = rotleft(bytemap, bits, width, pf->height); | 1137 | size = rotleft(bytemap, sizeof(bytemap), bits, width, pf->height); |
1129 | writestr(ofp, (char *)bytemap, size); | 1138 | writestr(ofp, (char *)bytemap, size); |
1130 | 1139 | ||
1131 | /* update offrot since bits are now in sorted order */ | 1140 | /* update offrot since bits are now in sorted order */ |