if(getnameinfo(sadr, addrlen, w->client_ip, NI_MAXHOST, w->client_port, NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
error("Cannot getnameinfo() on received client connection.");
- strncpy(w->client_ip, "UNKNOWN", NI_MAXHOST);
- strncpy(w->client_port, "UNKNOWN", NI_MAXSERV);
+ strncpyz(w->client_ip, "UNKNOWN", NI_MAXHOST);
+ strncpyz(w->client_port, "UNKNOWN", NI_MAXSERV);
}
w->client_ip[NI_MAXHOST] = '\0';
w->client_port[NI_MAXSERV] = '\0';
// access the file
char webfilename[FILENAME_MAX + 1];
- snprintf(webfilename, FILENAME_MAX, "%s/%s", web_dir, filename);
+ snprintfz(webfilename, FILENAME_MAX, "%s/%s", web_dir, filename);
// check if the file exists
struct stat stat;
}
if((stat.st_mode & S_IFMT) == S_IFDIR) {
- snprintf(webfilename, FILENAME_MAX+1, "%s/index.html", filename);
+ snprintfz(webfilename, FILENAME_MAX, "%s/index.html", filename);
return mysendfile(w, webfilename);
}
debug(D_WEB_CLIENT_ACCESS, "%llu: Cannot understand '%s'.", w->id, w->response.data->buffer);
+<<<<<<< HEAD
code = 500;
buffer_flush(w->response.data);
buffer_strcat(w->response.data, "I don't understand you...\r\n");
global_statistics_lock();
global_statistics.web_requests++;
global_statistics_unlock();
+=======
+ if(w->mode == WEB_CLIENT_MODE_OPTIONS) {
+ strncpyz(w->last_url, url, URL_MAX);
+>>>>>>> fredericopissarra/changes
// copy the URL - we are going to overwrite parts of it
// FIXME -- we should avoid it
web_client_enable_deflate(w);
#endif
+<<<<<<< HEAD
char *url = w->decoded_url;
char *tok = mystrsep(&url, "/?");
+=======
+ strncpyz(w->last_url, url, URL_MAX);
+
+ tok = mystrsep(&url, "/?");
+>>>>>>> fredericopissarra/changes
if(tok && *tok) {
debug(D_WEB_CLIENT, "%llu: Processing command '%s'.", w->id, tok);
else {
code = 200;
debug_flags |= D_RRD_STATS;
- st->debug = st->debug?0:1;
+ st->debug = !st->debug;
buffer_sprintf(w->response.data, "Chart %s has now debug %s.\r\n", tok, st->debug?"enabled":"disabled");
debug(D_WEB_CLIENT_ACCESS, "%llu: debug for %s is %s.", w->id, tok, st->debug?"enabled":"disabled");
}
else {
char filename[FILENAME_MAX+1];
url = filename;
- strncpy(filename, w->last_url, FILENAME_MAX);
- filename[FILENAME_MAX] = '\0';
+ strncpyz(filename, w->last_url, FILENAME_MAX);
tok = mystrsep(&url, "?");
buffer_flush(w->response.data);
code = mysendfile(w, (tok && *tok)?tok:"/");
else {
char filename[FILENAME_MAX+1];
url = filename;
- strncpy(filename, w->last_url, FILENAME_MAX);
- filename[FILENAME_MAX] = '\0';
+ strncpyz(filename, w->last_url, FILENAME_MAX);
tok = mystrsep(&url, "?");
buffer_flush(w->response.data);
code = mysendfile(w, (tok && *tok)?tok:"/");