Apiize CtdlIsPublicClient()
[citadel.git] / citadel / file_ops.c
index 75670266b73d9a5aec9382d4ab9f18de5840b43c..098554cd90d57b741768dca26bde49862349c935 100644 (file)
 #include "msgbase.h"
 #include "citserver.h"
 #include "threads.h"
-
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
 #include "ctdl_module.h"
 #include "user_ops.h"
 
@@ -208,6 +203,12 @@ void cmd_open(char *cmdbuf)
                        ERROR + FILE_NOT_FOUND);
                return;
        }
+       if (strstr(filename, "../") != NULL)
+       {
+               cprintf("%d syntax error.\n",
+                       ERROR + ILLEGAL_VALUE);
+               return;
+       }
 
        if (CC->download_fp != NULL) {
                cprintf("%d You already have a download file open.\n",
@@ -289,6 +290,13 @@ void cmd_oimg(char *cmdbuf)
                                filename[a] = '_';
                        }
                }
+               if (strstr(filename, "../") != NULL)
+               {
+                       cprintf("%d syntax error.\n",
+                               ERROR + ILLEGAL_VALUE);
+                       return;
+               }
+
                snprintf(pathname, sizeof pathname,
                                 "%s/%s",
                                 ctdl_image_dir,
@@ -537,6 +545,8 @@ void cmd_ucls(char *cmd)
                        );
 
                        if (link(CC->upl_path, final_filename) == 0) {
+                               syslog(LOG_INFO, "UCLS: updoaded %s\n",
+                                      final_filename);
                                unlink(CC->upl_path);
                        }
                        else {
@@ -544,6 +554,7 @@ void cmd_ucls(char *cmd)
                                        CC->upl_path, final_filename, strerror(errno)
                                );
                        }
+                       
 
                        /* FIXME ... here we need to trigger a network run */
                }
@@ -610,8 +621,13 @@ void cmd_read(char *cmdbuf)
        }
 
        rc = fseek(CC->download_fp, start_pos, 0);
-       if (rc != start_pos) {
+       if (rc < 0) {
                cprintf("%d your file is smaller then %ld.\n", ERROR + ILLEGAL_VALUE, start_pos);
+               syslog(LOG_ALERT, "your file %s is smaller then %ld. [%s]\n", 
+                      CC->upl_path, 
+                      start_pos,
+                      strerror(errno));
+
                return;
        }
        bytes = fread(buf, 1, bytes, CC->download_fp);