Package: webalizer / 2.23.08-3.1

01_symlink_vulnerability.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From: Julien Viard de Galbert <julien@vdg.blogsite.org>
Date: Tue, 23 Nov 2010 23:29:54 +0100
Subject: Solve a symlink vulnerability

In the same spirit as previous 08_symlink_vulnerability patch for #359745
The .htaccess file creation did not test the symlink.

Index: webalizer/output.c
===================================================================
--- webalizer.orig/output.c	2010-11-24 14:34:36.000000000 +0100
+++ webalizer/output.c	2010-11-24 14:36:56.000000000 +0100
@@ -2408,6 +2408,21 @@
    /* .htaccess file needed? */
    if (htaccess)
    {
+      struct stat out_stat;
+
+      /* stat the file */
+      if ( !(lstat(".htaccess", &out_stat)) )
+      {
+         /* check if the file a symlink */
+         if ( S_ISLNK(out_stat.st_mode) )
+         {
+            if (verbose)
+	    fprintf(stderr,"%s %s (symlink)\n",msg_no_open,".htaccess");
+            return NULL;
+         }
+      }
+
+      /* open the file... */
       if ((out_fp=fopen(".htaccess","wx")) != NULL)
       {
          fprintf(out_fp,"DirectoryIndex %s\n",index_fname);