Skip to content

Commit

Permalink
Fixed issue #1495
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed Jan 11, 2024
1 parent d816b89 commit 46e6ec9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* Issue #1525: Fixed a bug about cutting of http headers for distributed requests
* Issue #1525: Fixed a bug about cutting of HTTP headers for distributed requests
* Issue #1495: Fixed a CRASH about HTTP headers longer than 255 bytes for notifications over HTTPS
13 changes: 8 additions & 5 deletions src/lib/orionld/notifications/httpsNotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,15 @@ int httpsNotify(CachedSubscription* cSubP, struct iovec* ioVec, int ioVecLen, do
for (int ix = 1; ix < ioVecLen - 2; ix++)
{
// must not be CRLF-terminated - have to remove last 2 chars
char header[256];
strcpy(header, (char*) ioVec[ix].iov_base);
header[ioVec[ix].iov_len - 2] = 0;
char header[256];
uint32_t headerLen = strlen((char*) ioVec[ix].iov_base);
char* headerP = (headerLen < sizeof(header) - 1)? header : kaAlloc(&orionldState.kalloc, headerLen + 1);

LM_T(LmtNotificationHeaders, ("%s: Notification Request Header: '%s'", cSubP->subscriptionId, header));
headers = curl_slist_append(headers, header);
strncpy(headerP, (char*) ioVec[ix].iov_base, headerLen - 1);
headerP[ioVec[ix].iov_len - 2] = 0;

LM_T(LmtNotificationHeaders, ("%s: Notification Request Header: '%s'", cSubP->subscriptionId, headerP));
headers = curl_slist_append(headers, headerP);
}
curl_easy_setopt(curlHandleP, CURLOPT_HTTPHEADER, headers);

Expand Down
14 changes: 8 additions & 6 deletions test/functionalTest/cases/0000_ngsild/ngsild_issue_1495.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ accumulatorStart --pretty-print --https --key /tmp/harnessTest.key --cert /tmp/h

#
# 01. Create an HTTPS subscription, according to issue #1496
# 02. Do an upsert/update creating an entity, provoking a notification (issue #1496 says crash)
# 02. Do an upsert/update creating an entity, provoking a notification, using a very long Authorization header (issue #1496 says crash)
# 03. Dump/Reset the accumulator, see the entity
# 04. Do another upsert/update modifying the entity, provoking another notification (issue #1496 says crash)
# 05. Dump/Reset the accumulator, see the modified entity
Expand Down Expand Up @@ -66,8 +66,9 @@ echo
echo


echo "02. Do an upsert/update creating an entity, provoking a notification (issue #1496 says crash)"
echo "============================================================================================="
echo "02. Do an upsert/update creating an entity, provoking a notification, using a very long Authorization header (issue #1496 says crash)"
echo "====================================================================================================================================="
Authorization="Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJCT0JsSEliWlV1ZHFydmpPQjZXbktBaHlFdU1IdWViZ2RkOXNKS3U5RWNFIn0.eyJleHAiOjE3ODk0OTE4MjEsImlhdCI6MTcwMzE3ODIyMSwianRpIjoiODFlNmVmNTktZTExZC00YjI1LWE5ZTAtZWNhNDQzNDkxYTBlIiwiaXNzIjoiaHR0cDovLzE1OC40Mi4xNjEuMTc3OjMxNTUxL2F1dGgvcmVhbG1zL21hc3RlciIsImF1ZCI6WyJtYXN0ZXItcmVhbG0iLCJhY2NvdW50Il0sInN1YiI6IjU2NjAwOWQ3LWJlMWUtNGYxZC05OWY2LTdiMjBkZmVlMDAyZiIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFlcm9zIiwic2Vzc2lvbl9zdGF0ZSI6ImNkZTk5OTQ2LTUwM2UtNDY2OS04NDU2LTdlMjhhODQ2MzdhOSIsImFjciI6IjEiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsiY3JlYXRlLXJlYWxtIiwiZGVmYXVsdC1yb2xlcy1tYXN0ZXIiLCJvZmZsaW5lX2FjY2VzcyIsImFkbWluIiwiZG9tYWluX2FkbWlucyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWVyb3MiOnsicm9sZXMiOlsidXB2X3JvbGVfMSJ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XUF4W1wI2WyW36glEkCDdnZpbGhQXqtpFlxg"
payload='[
{
"id": "urn:ngsi-ld:WeatherObserved:AIS:owm:5419982",
Expand Down Expand Up @@ -121,7 +122,7 @@ payload='[
}
}
]'
orionCurl --url /ngsi-ld/v1/entityOperations/upsert?options=update --payload "$payload"
orionCurl --url /ngsi-ld/v1/entityOperations/upsert?options=update --payload "$payload" -H "Authorization: $Authorization"
echo
echo

Expand Down Expand Up @@ -219,8 +220,8 @@ Location: /ngsi-ld/v1/subscriptions/urn:ngsi-ld:subscription:d6652902-99cd-11ee-



02. Do an upsert/update creating an entity, provoking a notification (issue #1496 says crash)
=============================================================================================
02. Do an upsert/update creating an entity, provoking a notification, using a very long Authorization header (issue #1496 says crash)
=====================================================================================================================================
HTTP/1.1 201 Created
Content-Length: 47
Content-Type: application/json
Expand All @@ -235,6 +236,7 @@ Date: REGEX(.*)
==============================================
POST https://127.0.0.1/notify
Content-Length: 590
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJCT0JsSEliWlV1ZHFydmpPQjZXbktBaHlFdU1IdWViZ2RkOXNKS3U5RWNFIn0.eyJleHAiOjE3ODk0OTE4MjEsImlhdCI6MTcwMzE3ODIyMSwianRpIjoiODFlNmVmNTktZTExZC00YjI1LWE5ZTAtZWNhNDQzNDkxYTBlIiwiaXNzIjoiaHR0cDovLzE1OC40Mi4xNjEuMTc3OjMxNTUxL2F1dGgvcmVhbG1zL21hc3RlciIsImF1ZCI6WyJtYXN0ZXItcmVhbG0iLCJhY2NvdW50Il0sInN1YiI6IjU2NjAwOWQ3LWJlMWUtNGYxZC05OWY2LTdiMjBkZmVlMDAyZiIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFlcm9zIiwic2Vzc2lvbl9zdGF0ZSI6ImNkZTk5OTQ2LTUwM2UtNDY2OS04NDU2LTdlMjhhODQ2MzdhOSIsImFjciI6IjEiLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMi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-UE8uj60zZKwXwQVapP7LhowraQpGeiwirGDZc9DV5at8pMR2gH3c88KSVtudxJQUcwm7wt0qvlX0M1eDJOo4YYjs41mIQiBWmIxantt3qXapk7ZzyByp3sp2Kzo6wJVAcJRlkoIsXBxAh6n5D1gerJzwh0f5OZMpxgjwCF3Jjps4Wjkh0je-CHFF-x0cSIS_LsqbPgys--mmuxyeXUF4W1wI2WyW36glEkCDdnZpbGhQXqtpFlxg
User-Agent: orionld/REGEX(.*)
Host: 127.0.0.1
Accept: application/json
Expand Down

0 comments on commit 46e6ec9

Please sign in to comment.