Skip to content

Commit

Permalink
Merge pull request #103 from ak0327/fix/envp
Browse files Browse the repository at this point in the history
Fix/envp
  • Loading branch information
ak0327 authored Mar 9, 2024
2 parents 825d35e + 4335132 commit f4ce7c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NAME = webserv
CXX = c++
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror -MMD -MP -pedantic
#CXXFLAGS += -g -fsanitize=address,undefined -fno-omit-frame-pointer
CXXFLAGS += -D DEBUG
#CXXFLAGS += -D DEBUG

# SRCS -------------------------------------------------------------------------
SRCS_DIR = srcs
Expand Down Expand Up @@ -220,7 +220,7 @@ clean :

.PHONY : fclean
fclean : clean
rm -f $(NAME) client
rm -f $(NAME)

.PHONY : re
re : fclean all
Expand Down
6 changes: 6 additions & 0 deletions srcs/HttpResponse/CgiHandler/CgiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <unistd.h>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <limits>
Expand Down Expand Up @@ -176,6 +177,11 @@ char **CgiHandler::create_envp(const CgiParams &params) {
env_strings.push_back(make_key_value_pair("PATH_INFO", params.path_info));
env_strings.push_back(make_key_value_pair("SCRIPT_NAME", params.script_path));

char *path_env = std::getenv("PATH");
if (path_env != NULL) {
env_strings.push_back((make_key_value_pair("PATH", path_env)));
}

char **envp = NULL;
try {
envp = new char*[env_strings.size() + 1];
Expand Down

0 comments on commit f4ce7c4

Please sign in to comment.