merged PR #395
Costa Tsaousis committed
May 13, 2016 at 20:12 UTC
6d4cc4eb272d47acb6cfc9e3fedd29b4075a7ba5
1 file changed
+6
-20
src/web_client.c
+6
-20
@@ -802,10 +802,8 @@ int web_client_api_request_v1_registry(struct web_client *w, char *url)
802
debug(D_WEB_CLIENT, "%llu: API v1 registry with URL '%s'", w->id, url);
803
804
char *cookie = strstr(w->response.data->buffer, " " NETDATA_REGISTRY_COOKIE_NAME "=");
805
- if(cookie) {
806
- strncpy(person_guid, &cookie[sizeof(NETDATA_REGISTRY_COOKIE_NAME) + 1], 36);
807
- person_guid[36] = '\0';
808
- }
805
+ if(cookie)
806
+ strncpyz(person_guid, &cookie[sizeof(NETDATA_REGISTRY_COOKIE_NAME) + 1], 36);
807
808
char action = '\0';
809
char *machine_guid = NULL,
@@ -1210,9 +1208,9 @@ static inline char *http_header_parse(struct web_client *w, char *s) {
1208
1209
// fprintf(stderr, "HEADER: '%s' = '%s'\n", s, v);
1210
1213
- if(!strcasecmp(s, "Origin")) {
1214
- strncpy(w->origin, v, ORIGIN_MAX);
1215
- }
1211
+ if(!strcasecmp(s, "Origin"))
1212
+ strncpyz(w->origin, v, ORIGIN_MAX);
1213
+
1214
else if(!strcasecmp(s, "Connection")) {
1215
if(strcasestr(v, "keep-alive"))
1216
w->keepalive = 1;
@@ -1332,7 +1330,6 @@ void web_client_process(struct web_client *w) {
1330
1331
debug(D_WEB_CLIENT_ACCESS, "%llu: Cannot understand '%s'.", w->id, w->response.data->buffer);
1332
1335
-<<<<<<< HEAD
1333
code = 500;
1334
buffer_flush(w->response.data);
1335
buffer_strcat(w->response.data, "I don't understand you...\r\n");
@@ -1343,15 +1340,10 @@ void web_client_process(struct web_client *w) {
1340
global_statistics_lock();
1341
global_statistics.web_requests++;
1342
global_statistics_unlock();
1346
-=======
1347
- if(w->mode == WEB_CLIENT_MODE_OPTIONS) {
1348
- strncpyz(w->last_url, url, URL_MAX);
1349
->>>>>>> fredericopissarra/changes
1343
1344
// copy the URL - we are going to overwrite parts of it
1345
// FIXME -- we should avoid it
1353
- strncpy(w->last_url, w->decoded_url, URL_MAX);
1354
- w->last_url[URL_MAX] = '\0';
1346
+ strncpyz(w->last_url, w->decoded_url, URL_MAX);
1347
1348
if(w->mode == WEB_CLIENT_MODE_OPTIONS) {
1349
code = 200;
@@ -1365,14 +1357,8 @@ void web_client_process(struct web_client *w) {
1357
web_client_enable_deflate(w);
1358
#endif
1359
1368
-<<<<<<< HEAD
1360
char *url = w->decoded_url;
1361
char *tok = mystrsep(&url, "/?");
1371
-=======
1372
- strncpyz(w->last_url, url, URL_MAX);
1373
-
1374
- tok = mystrsep(&url, "/?");
1375
->>>>>>> fredericopissarra/changes
1362
if(tok && *tok) {
1363
debug(D_WEB_CLIENT, "%llu: Processing command '%s'.", w->id, tok);
1364