Skip to content

Commit

Permalink
Better fd handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen committed Dec 22, 2011
1 parent 542f8f2 commit 01472aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
OWNER=root
GROUP=root
CC=gcc
CFLAGS=-O2 -Wall -fno-tree-vrp
CFLAGS=-O2 -Wall
LIBS=-ldb
SBINDIR=/usr/sbin

Expand Down
10 changes: 9 additions & 1 deletion squidguard.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ int squidguard_closefd(FILE *sg_fd[2]) {
int squidguard_backend(FILE *sg_fd[2], char srcip[15], char url[URL_SIZE], int debug) {
char redirect_url[URL_SIZE];

if (sg_fd[1] == NULL) {
syslog(LOG_WARNING, "squidguard: could not open fd for input.");
return 0;
}
fprintf(sg_fd[1], "%s %s/ - - GET\n", url, srcip);
fflush(sg_fd[1]);

if (sg_fd[0] == NULL) {
syslog(LOG_WARNING, "squidguard: could not open fd for output.");
return 0;
}
while (fgets(redirect_url, URL_SIZE, sg_fd[0]) != NULL) {
redirect_url[strlen(redirect_url) - 1] = '\0';
if (debug > 1)
syslog(LOG_INFO, "squidguard: redirect_url (%s).", redirect_url);
if (strlen(redirect_url) > 1) {
Expand Down

0 comments on commit 01472aa

Please sign in to comment.