aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2021-01-11 19:42:44 +0000
committerToomas Soome <tsoome@FreeBSD.org>2021-01-11 22:56:35 +0000
commit2c52512caf6ec10f49038e6884b9c2aea905cc4e (patch)
treed84443de9fc143051d34f87d4ff5f58552321c05 /contrib
parent86b653ed7eedb0d6cc3315bea132f847f748066d (diff)
downloadsrc-2c52512caf6ec10f49038e6884b9c2aea905cc4e.tar.gz
src-2c52512caf6ec10f49038e6884b9c2aea905cc4e.zip
pnglite: should use ntohl
Replace manual conversion with ntohl()
Diffstat (limited to 'contrib')
-rw-r--r--contrib/pnglite/pnglite.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/contrib/pnglite/pnglite.c b/contrib/pnglite/pnglite.c
index e3cc2f866c6f..f517b6bdcaa5 100644
--- a/contrib/pnglite/pnglite.c
+++ b/contrib/pnglite/pnglite.c
@@ -52,12 +52,12 @@ file_read(png_t *png, void *out, size_t size, size_t numel)
static int
file_read_ul(png_t *png, unsigned *out)
{
- uint8_t buf[4];
+ uint32_t buf;
- if (file_read(png, buf, 1, 4) != 4)
+ if (file_read(png, &buf, 1, 4) != 4)
return (PNG_FILE_ERROR);
- *out = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
+ *out = ntohl(buf);
return (PNG_NO_ERROR);
}
@@ -65,14 +65,7 @@ file_read_ul(png_t *png, unsigned *out)
static unsigned
get_ul(uint8_t *buf)
{
- unsigned result;
- uint8_t foo[4];
-
- memcpy(foo, buf, 4);
-
- result = (foo[0]<<24) | (foo[1]<<16) | (foo[2]<<8) | foo[3];
-
- return (result);
+ return (ntohl(*(uint32_t *)buf));
}
static int