diff options
-rw-r--r-- | apps/wps-display.c | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/apps/wps-display.c b/apps/wps-display.c index e7c5472ea9..1b7b76547a 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c | |||
@@ -758,9 +758,9 @@ static void format_display(char* buf, | |||
758 | int n; | 758 | int n; |
759 | #ifdef HAVE_LCD_BITMAP | 759 | #ifdef HAVE_LCD_BITMAP |
760 | int ret; | 760 | int ret; |
761 | const char *pos, *posn; | 761 | char *pos, *posn; |
762 | char imgtmp[32]; | ||
763 | char imgname[MAX_PATH]; | 762 | char imgname[MAX_PATH]; |
763 | char *ptr; | ||
764 | #endif | 764 | #endif |
765 | 765 | ||
766 | *subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER; | 766 | *subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER; |
@@ -803,47 +803,55 @@ static void format_display(char* buf, | |||
803 | #ifdef HAVE_LCD_BITMAP | 803 | #ifdef HAVE_LCD_BITMAP |
804 | /* get image number */ | 804 | /* get image number */ |
805 | pos = strchr(fmt, '|'); /* get the first '|' */ | 805 | pos = strchr(fmt, '|'); /* get the first '|' */ |
806 | if ((pos - fmt) < 32) { | 806 | ptr = (char *)fmt+1; |
807 | strncpy(imgtmp, fmt+1, pos - fmt - 1); | 807 | if (pos && ((pos - ptr) < (int)sizeof(temp_buf))) { |
808 | imgtmp[pos - fmt - 1] = 0; | 808 | memcpy(temp_buf, ptr, pos - ptr); |
809 | n = atoi(imgtmp); | 809 | temp_buf[pos - ptr] = 0; |
810 | n = atoi(temp_buf); | ||
811 | ptr = pos+1; | ||
810 | 812 | ||
811 | /* check image number, and load state. */ | 813 | /* check image number, and load state. */ |
812 | if ((n < MAX_IMAGES) && (!img[n].loaded)) { | 814 | if ((n < MAX_IMAGES) && (!img[n].loaded)) { |
813 | /* Get filename */ | 815 | /* Get filename */ |
814 | pos = strchr(fmt+3, '|'); /* get the second '|' */ | 816 | pos = strchr(ptr, '|'); /* get the second '|' */ |
815 | if ((pos - fmt) < 32) { | 817 | if ((pos - ptr) < (int)sizeof(temp_buf)) { |
816 | strncpy(imgtmp, fmt+3, pos - fmt - 3); /* get the filename */ | 818 | memcpy(temp_buf, ptr, pos - ptr); /* get the filename */ |
817 | imgtmp[pos - fmt - 3] = 0; | 819 | temp_buf[pos - ptr] = 0; |
818 | } else { | 820 | snprintf(imgname, MAX_PATH, "/.rockbox/%s", temp_buf); |
819 | /* hm.. filename is to long... */ | 821 | } |
820 | *imgtmp = 0; | 822 | else { |
823 | /* filename too long! */ | ||
824 | imgname[0]=0; | ||
821 | } | 825 | } |
822 | snprintf(imgname, MAX_PATH, "/.rockbox/%s", imgtmp); | ||
823 | 826 | ||
824 | /* Get X-position */ | 827 | /* Get X-position */ |
825 | posn = strchr(pos+1, '|'); /* get the 3th '|' */ | 828 | ptr=pos+1; |
826 | if ((posn - fmt) < 32) { | 829 | posn = strchr(ptr, '|'); /* get the 3th '|' */ |
827 | strncpy(imgtmp, pos+1, posn - pos - 1); | 830 | if ((posn - ptr) < (int)sizeof(temp_buf)) { |
828 | imgtmp[posn - pos - 1] = 0; | 831 | memcpy(temp_buf, ptr, posn - ptr); |
829 | img[n].x = atoi(imgtmp); | 832 | temp_buf[posn - ptr] = 0; |
830 | } else { | 833 | img[n].x = atoi(temp_buf); |
831 | img[n].x = 0; | ||
832 | } | 834 | } |
835 | else | ||
836 | /* weird syntax, get out */ | ||
837 | break; | ||
833 | 838 | ||
834 | /* Get Y-position */ | 839 | /* Get Y-position */ |
835 | pos = posn; | 840 | pos = posn; |
836 | posn = strchr(pos+1, '|'); /* get the 4th '|' */ | 841 | ptr = posn+1; |
837 | if ((posn - fmt) < 32) { | 842 | posn = strchr(ptr, '|'); /* get the 4th '|' */ |
838 | strncpy(imgtmp, pos+1, posn - pos - 1); | 843 | if ((posn - ptr) < (int)sizeof(temp_buf)) { |
839 | imgtmp[posn - pos - 1] = 0; | 844 | memcpy(temp_buf, ptr, posn - ptr); |
840 | img[n].y = atoi(imgtmp); | 845 | temp_buf[posn - ptr] = 0; |
841 | } else { | 846 | img[n].y = atoi(temp_buf); |
842 | img[n].y = 0; | ||
843 | } | 847 | } |
848 | else | ||
849 | /* weird syntax, get out */ | ||
850 | break; | ||
844 | 851 | ||
845 | /* and load the image */ | 852 | /* and load the image */ |
846 | ret = read_bmp_file(imgname, &img[n].w, &img[n].h, img_buf_ptr, img_buf_free); | 853 | ret = read_bmp_file(imgname, &img[n].w, &img[n].h, img_buf_ptr, |
854 | img_buf_free); | ||
847 | if (ret > 0) { | 855 | if (ret > 0) { |
848 | img[n].ptr = img_buf_ptr; | 856 | img[n].ptr = img_buf_ptr; |
849 | img_buf_ptr += ret; | 857 | img_buf_ptr += ret; |