Permalink
Browse files

- lophttpd: removing VLA's (ISO C++11 cleanups)

  • Loading branch information...
stealth committed Feb 28, 2014
1 parent 91e493f commit 8b938bac0e2da02a5e81f03c4247de54c4a246f6
Showing with 32 additions and 15 deletions.
  1. +1 −1 LICENSE
  2. +1 −1 Makefile
  3. +2 −2 Makefile.osx
  4. +4 −1 client.cc
  5. +6 −2 flavor-android.cc
  6. +8 −3 flavor-bsd.cc
  7. +5 −2 flavor-linux.cc
  8. +5 −3 flavor-osx.cc
View
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008 Sebastian Krahmer.
* Copyright (C) 2008-2014 Sebastian Krahmer.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
View
@@ -12,7 +12,7 @@ LIBS=-lssl -lcrypto
#override lophttps secure cipher list
#DEFS+=-DUSE_CIPHERS=\"ALL:!ADH:!LOW:!EXP:!RC4:!MD5:@STRENGTH\"
CXX=c++ -Wall -O2 $(DEFS) -ansi
CXX=c++ -Wall -O2 $(DEFS) -ansi -std=c++11
LD=c++
all: lhttpd frontend
View
@@ -4,13 +4,13 @@
# You need to install Xcode and its commandline tools
DEFS=-ansi -DUSE_SSL -w
DEFS=-DUSE_SSL
LIBS=-lssl -lcrypto
#override lophttps secure cipher list
#DEFS+=-DUSE_CIPHERS=\"ALL:!ADH:!LOW:!EXP:!RC4:!MD5:@STRENGTH\"
CXX=c++ -Wall -O2 $(DEFS)
CXX=c++ -w -O2 $(DEFS) -ansi -std=c++11
LD=c++
all: lhttpd frontend
View
@@ -40,6 +40,7 @@
#include "flavor.h"
#include "socket.h"
#include "client.h"
#include "lonely.h"
#ifdef USE_SSL
extern "C" {
@@ -114,13 +115,15 @@ ssize_t http_client::send(const char *buf, size_t n)
ssize_t http_client::sendfile(size_t n)
{
if (n > MAX_SEND_SIZE)
return -1;
#ifdef USE_SSL
if (ssl_enabled) {
ssize_t r = 0, l = 0;
// OK, n cannot be larger than MAX_SEND_SIZE
char buf[n], siz[32];
char buf[MAX_SEND_SIZE], siz[32];
r = pread(file_fd, buf, n, offset);
View
@@ -111,12 +111,16 @@ int in_send_queue(int fd)
ssize_t sendfile(int peer, int fd, off_t *offset, size_t n, size_t &left, size_t &copied, int ftype)
{
if (n > MAX_SEND_SIZE)
return -1;
ssize_t r = 0, l = 0;
// proc and sys files
if (ftype == FILE_PROC) {
char buf[n], siz[32];
r = pread(fd, buf, sizeof(buf), *offset);
// n cannot be larger than MAX_SEND_SIZE
char buf[MAX_SEND_SIZE], siz[32];
r = pread(fd, buf, n, *offset);
if (r < 0) {
if (errno == EAGAIN)
errno = EBADF;
View
@@ -105,13 +105,17 @@ int in_send_queue(int peer)
ssize_t sendfile(int peer, int fd, off_t *offset, size_t n, size_t &left, size_t &copied, int ftype)
{
if (n > MAX_SEND_SIZE)
return -1;
off_t sbytes = 0;
ssize_t r = 0, l = 0;
// proc files
if (ftype == FILE_PROC) {
char buf[n], siz[32];
r = pread(fd, buf, sizeof(buf), *offset);
// n cannot be larger than MAX_SEND_SIZE
char buf[MAX_SEND_SIZE], siz[32];
r = pread(fd, buf, n, *offset);
if (r < 0) {
if (errno == EAGAIN)
errno = EBADF;
@@ -147,7 +151,8 @@ ssize_t sendfile(int peer, int fd, off_t *offset, size_t n, size_t &left, size_t
r = (ssize_t)sbytes;
// On FreeBSD, device files do not support sendfile()
} else {
char buf[n];
// n cannot be larger than MAX_SEND_SIZE
char buf[MAX_SEND_SIZE];
r = pread(fd, buf, n, *offset);
if (r > 0) {
// write(), not writen()
View
@@ -103,13 +103,16 @@ int in_send_queue(int fd)
ssize_t sendfile(int peer, int fd, off_t *offset, size_t n, size_t &left, size_t &copied, int ftype)
{
if (n > MAX_SEND_SIZE)
return -1;
ssize_t r = 0, l = 0;
// proc and sys files
if (ftype == FILE_PROC) {
// OK, cannot be larger than MAX_SEND_SIZE
char buf[n], siz[32];
r = pread(fd, buf, sizeof(buf), *offset);
char buf[MAX_SEND_SIZE], siz[32];
r = pread(fd, buf, n, *offset);
if (r < 0) {
if (errno == EAGAIN)
errno = EBADF;
View
@@ -103,13 +103,15 @@ int in_send_queue(int fd)
ssize_t sendfile(int peer, int fd, off_t *offset, size_t n, size_t &left, size_t &copied, int ftype)
{
if (n > MAX_SEND_SIZE)
return -1;
ssize_t r = 0, l = 0;
char buf[n];
// proc and sys files
if (ftype == FILE_PROC) {
char siz[32];
r = pread(fd, buf, sizeof(buf), *offset);
char buf[MAX_SEND_SIZE], siz[32];
r = pread(fd, buf, n, *offset);
if (r < 0) {
if (errno == EAGAIN)
errno = EBADF;

0 comments on commit 8b938ba

Please sign in to comment.