aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-05-29 17:42:27 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-05-29 17:42:27 +0200
commit18998289da11226ea180b1f6bbcb103473d36b6c (patch)
tree8a5da339e05d170e7d9d959e0e7b28b151f79698
parent90536d7963fa30b3cb86b8797a7869612305073b (diff)
downloadcqrlogo-18998289da11226ea180b1f6bbcb103473d36b6c.tar.gz
cqrlogo-18998289da11226ea180b1f6bbcb103473d36b6c.tar.zst
add comments
-rw-r--r--cqrlogo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/cqrlogo.c b/cqrlogo.c
index b76fb13..43e353f 100644
--- a/cqrlogo.c
+++ b/cqrlogo.c
@@ -66,6 +66,7 @@ int main(int argc, char **argv) {
gchar *buffer;
gsize size;
+ /* check if we have environment variables from CGI */
if ((http_referer = getenv("HTTP_REFERER")) == NULL ||
(server_name = getenv("SERVER_NAME")) == NULL) {
printf("This is a CGI executable. Running without a web service is not supported.\n"
@@ -73,13 +74,14 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}
+ /* prepare pattern matching */
pattern = malloc(11 + strlen(server_name));
sprintf(pattern, "^http://%s/", server_name);
if ((rc = regcomp(&preg, pattern, 0)) != 0)
printf("regcomp() failed, returning nonzero (%d)\n", rc);
+ /* check if the QR-Code is for the correct server */
if ((rc = regexec(&preg, http_referer, nmatch, pmatch, 0)) != 0) {
- /* stolen... */
http_referer = malloc(44 + strlen(server_name));
sprintf(http_referer, "This QR Code has been stolen from http://%s/!", server_name);
}