Editing of account email addresses using the new server commands in WebCit-classic.
[citadel.git] / webcit / tcp_sockets.c
index 33889f665ffc998f81037cbd928aa5232c6cc8ad..f8705872ca938cc76892d9c20064aecafe77dd9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2017 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -293,12 +293,12 @@ void FlushReadBuf (void)
                pche = pch + len;
                if (WCC->ReadPos != pche)
                {
-                       syslog(LOG_EMERG,
+                       syslog(LOG_ERR,
                                "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", 
                                (long)(pche - WCC->ReadPos),
                                pche
                        );
-                       syslog(LOG_EMERG
+                       syslog(LOG_ERR
                                "--------------------------------------------------------------------------------\n"
                                "Whole buf: [%s]\n"
                                "--------------------------------------------------------------------------------\n", 
@@ -556,10 +556,11 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        int client_con_state = 0;
        int chunked = 0;
        int is_gzip = 0;
+       const char *Err = NULL;
        StrBuf *BufHeader = NULL;
        StrBuf *Buf;
        StrBuf *pBuf = NULL;
-       void *SC = NULL;
+       vStreamT *SC = NULL;
        IOBuffer ReadBuffer;
        IOBuffer WriteBuffer;
        
@@ -613,7 +614,12 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
        if (chunked && !DisableGzip && WCC->Hdr->HR.gzip_ok)
        {
                is_gzip = 1;
-               SC = StrBufNewStreamContext (eZLibEncode);
+               SC = StrBufNewStreamContext (eZLibEncode, &Err);
+               if (SC == NULL) {
+                       syslog(LOG_ERR, "Error while initializing stream context: %s", Err);
+                       FreeStrBuf(&Buf);
+                       return;
+               }
 
                memset(&ReadBuffer, 0, sizeof(IOBuffer));
                ReadBuffer.Buf = WCC->WBuf;
@@ -635,7 +641,9 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                        FreeStrBuf(&Buf);
                        FreeStrBuf(&WriteBuffer.Buf);
                        FreeStrBuf(&BufHeader);
-                       StrBufDestroyStreamContext(eZLibEncode, SC);
+                       if (StrBufDestroyStreamContext(eZLibEncode, &SC, &Err) && Err) {
+                               syslog(LOG_ERR, "Error while destroying stream context: %s", Err);
+                       }
                        return;
                }
        }
@@ -650,7 +658,10 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                        FreeStrBuf(&Buf);
                        FreeStrBuf(&WriteBuffer.Buf);
                        FreeStrBuf(&BufHeader);
-                       StrBufDestroyStreamContext(eZLibEncode, SC);
+                       StrBufDestroyStreamContext(eZLibEncode, &SC, &Err);
+                       if (StrBufDestroyStreamContext(eZLibEncode, &SC, &Err) && Err) {
+                               syslog(LOG_ERR, "Error while destroying stream context: %s", Err);
+                       }
                        return;
                }
 
@@ -684,7 +695,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                                int rc;
 
                                do {
-                                       rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done);
+                                       rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done, &Err);
 
                                        if (StrLength (pBuf) > 0) {
                                                StrBufPrintf(BufHeader, "%s%x\r\n", 
@@ -718,7 +729,9 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
                }
        }
 
-       StrBufDestroyStreamContext(eZLibEncode, &SC);
+       if (SC && StrBufDestroyStreamContext(eZLibEncode, &SC, &Err) && Err) {
+               syslog(LOG_ERR, "Error while destroying stream context: %s", Err);
+       }
        FreeStrBuf(&WriteBuffer.Buf);
        if ((chunked) && (client_con_state == 0))
        {
@@ -888,13 +901,13 @@ retry:
        }
 
        if (b < 0) {
-               syslog(LOG_EMERG, "Can't bind: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Can't bind: %s\n", strerror(errno));
                close(s);
                return (-WC_EXIT_BIND);
        }
 
        if (listen(s, queue_len) < 0) {
-               syslog(LOG_EMERG, "Can't listen: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Can't listen: %s\n", strerror(errno));
                close(s);
                return (-WC_EXIT_BIND);
        }