summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--bin/gfxx.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/bin/gfxx.c b/bin/gfxx.c
index 6ccb17cb..5f05650c 100644
--- a/bin/gfxx.c
+++ b/bin/gfxx.c
@@ -28,9 +28,11 @@
 #include <unistd.h>
 #include <zlib.h>
 
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MASK(b) ((1 << (b)) - 1)
+
 #define RGB(r, g, b) ((uint32_t)(r) << 16 | (uint32_t)(g) << 8 | (uint32_t)(b))
 #define GRAY(n) RGB(n, n, n)
-#define MASK(b) ((1 << (b)) - 1)
 
 static enum {
     COLOR_INDEXED,
@@ -351,7 +353,8 @@ static void pngDump(uint32_t *src, size_t srcWidth, size_t srcHeight) {
         pngWrite(options, strlen(options));
     }
     PNG_CHUNK("sBIT", 3) {
-        pngWrite(&bits[R], 3);
+        uint8_t sbit[3] = { MAX(bits[R], 1), MAX(bits[G], 1), MAX(bits[B], 1) };
+        pngWrite(sbit, sizeof(sbit));
     }
     PNG_CHUNK("IDAT", dataSize) {
         pngWrite(data, dataSize);
By default, strings are compared by hash, so we can remove this comment. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16authentication: use hidden form instead of refererJason A. Donenfeld This also gives us some CSRF protection. Note that we make use of the hmac to protect the redirect value. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16auth: add basic authentication filter frameworkJason A. Donenfeld This leverages the new lua support. See filters/simple-authentication.lua for explaination of how this works. There is also additional documentation in cgitrc.5.txt. Though this is a cookie-based approach, cgit's caching mechanism is preserved for authenticated pages. Very plugable and extendable depending on user needs. The sample script uses an HMAC-SHA1 based cookie to store the currently logged in user, with an expiration date. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16t0111: Additions and fixesLukas Fleischer * Rename the capitalize-* filters to dump.* since they also dump the arguments. * Add full argument validation to the email filters. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-16parsing.c: Remove leading space from committerLukas Fleischer