summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2005-07-10 06:25:09 +0000
committerjsorg71 <jsorg71>2005-07-10 06:25:09 +0000
commit196bfa81d6eb601d35024f117e8aa988657c8569 (patch)
treeef5dae14f95740a2bc56d2550af297a67bd01988
parent7ffee77e6d6117c8055c121cf72958d045e41e8a (diff)
downloadxrdp-proprietary-196bfa81d6eb601d35024f117e8aa988657c8569.tar.gz
xrdp-proprietary-196bfa81d6eb601d35024f117e8aa988657c8569.zip
big endian fix
-rw-r--r--xrdp/xrdp_bitmap.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index d51fb1ce..ac25a23d 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -335,7 +335,9 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, char* filename, int* palette)
char type1[3];
char* data;
struct xrdp_bmp_header header;
+ struct stream* s;
+ s = 0;
fd = g_file_open(filename);
if (fd != -1)
{
@@ -355,9 +357,23 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, char* filename, int* palette)
g_file_read(fd, (char*)&size, 4);
/* read bmp header */
g_file_seek(fd, 14);
- g_file_read(fd, (char*)&header, sizeof(header));
+ make_stream(s);
+ init_stream(s, 8192);
+ g_file_read(fd, s->data, 40); /* size better be 40 */
+ in_uint32_le(s, header.size);
+ in_uint32_le(s, header.image_width);
+ in_uint32_le(s, header.image_height);
+ in_uint16_le(s, header.planes);
+ in_uint16_le(s, header.bit_count);
+ in_uint32_le(s, header.compression);
+ in_uint32_le(s, header.image_size);
+ in_uint32_le(s, header.x_pels_per_meter);
+ in_uint32_le(s, header.y_pels_per_meter);
+ in_uint32_le(s, header.clr_used);
+ in_uint32_le(s, header.clr_important);
if (header.bit_count != 8 && header.bit_count != 24)
{
+ free_stream(s);
g_file_close(fd);
return 1;
}
@@ -369,7 +385,12 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, char* filename, int* palette)
{
/* read palette */
g_file_seek(fd, 14 + header.size);
- g_file_read(fd, (char*)palette1, 256 * sizeof(int));
+ init_stream(s, 8192);
+ g_file_read(fd, s->data, 256 * sizeof(int));
+ for (i = 0; i < 256; i++)
+ {
+ in_uint32_le(s, palette1[i]);
+ }
/* read data */
xrdp_bitmap_resize(self, header.image_width, header.image_height);
data = (char*)g_malloc(header.image_width * header.image_height, 1);
@@ -412,6 +433,7 @@ xrdp_bitmap_load(struct xrdp_bitmap* self, char* filename, int* palette)
}
g_file_close(fd);
}
+ free_stream(s);
return 0;
}