Skip to content

Commit

Permalink
Fix zero length string bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Nov 25, 2019
1 parent a076ce3 commit d280545
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Realtime Database Arduino Library for ESP8266


Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.7.0
Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.7.1


This library supports ESP8266 MCU from Espressif. The following are platforms which library are also available.
Expand Down Expand Up @@ -48,7 +48,7 @@ This library supports ESP8266 MCU from Espressif. The following are platforms wh

## Changes from earlier version

For library v 2.7.0 (comes with FirebaseJson v 2.2.7) or later, FirebaseJson object will be used to handle JSON data instead of JSON string which, the following functions are affected:
For library v 2.7.1 (comes with FirebaseJson v 2.2.7) or later, FirebaseJson object will be used to handle JSON data instead of JSON string which, the following functions are affected:

getJson, setJson, pushJson, updateNode and updateNodeSilent.

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=Firebase ESP8266 Client

version=2.7.0
version=2.7.1

author=Mobizt

Expand Down
42 changes: 26 additions & 16 deletions src/FirebaseESP8266.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.7.0
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.7.1
*
* November 15, 2019
* November 25, 2019
*
* Feature Added:
*
* Feature Fixed:
* - Fix FirebaseJson set/remove bugs.
* - Fix zero length string bugs.
*
*
* This library provides ESP8266 to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update
Expand Down Expand Up @@ -2884,21 +2884,25 @@ bool FirebaseESP8266::getServerResponse(FirebaseData &dataObj)
memset(lineBuf, 0, FIREBASE_RESPONSE_SIZE);
}

memset(fstr, 0, 60);
strcpy_P(fstr, ESP8266_FIREBASE_STR_14);

p1 = strpos(lineBuf, fstr, 0);
if (p1 != -1)
if (strlen(lineBuf) > 0)
{
hasEventData = true;
isStream = true;
dataObj._httpCode = _HTTP_CODE_OK;

memset(tmp, 0, tempBufSize);
strncpy(tmp, lineBuf + p1 + strlen_P(ESP8266_FIREBASE_STR_14), strlen(lineBuf) - p1 - strlen_P(ESP8266_FIREBASE_STR_14));
memset(lineBuf, 0, FIREBASE_RESPONSE_SIZE);
strcpy(lineBuf, tmp);
break;
memset(fstr, 0, 60);
strcpy_P(fstr, ESP8266_FIREBASE_STR_14);

p1 = strpos(lineBuf, fstr, 0);
if (p1 != -1)
{
hasEventData = true;
isStream = true;
dataObj._httpCode = _HTTP_CODE_OK;

memset(tmp, 0, tempBufSize);
strncpy(tmp, lineBuf + p1 + strlen_P(ESP8266_FIREBASE_STR_14), strlen(lineBuf) - p1 - strlen_P(ESP8266_FIREBASE_STR_14));
memset(lineBuf, 0, FIREBASE_RESPONSE_SIZE);
strcpy(lineBuf, tmp);
break;
}
}
}
}
Expand Down Expand Up @@ -5591,6 +5595,9 @@ void FirebaseESP8266::strcat_c(char *str, char c)
int FirebaseESP8266::strpos(const char *haystack, const char *needle, int offset)
{
size_t len = strlen(haystack);
size_t len2 = strlen(needle);
if (len == 0 || len < len2 || len2 == 0)
return -1;
char *_haystack = new char[len];
memset(_haystack, 0, len);
strncpy(_haystack, haystack + offset, strlen(haystack) - offset);
Expand All @@ -5605,6 +5612,9 @@ int FirebaseESP8266::strpos(const char *haystack, const char *needle, int offset
int FirebaseESP8266::rstrpos(const char *haystack, const char *needle, int offset)
{
size_t len = strlen(haystack);
size_t len2 = strlen(needle);
if (len == 0 || len < len2 || len2 == 0)
return -1;
char *_haystack = new char[len];
memset(_haystack, 0, len);
strncpy(_haystack, haystack + offset, len - offset);
Expand Down
6 changes: 3 additions & 3 deletions src/FirebaseESP8266.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.7.0
* Google's Firebase Realtime Database Arduino Library for ESP8266, version 2.7.1
*
* November 15, 2019
* November 25, 2019
*
* Feature Added:
*
* Feature Fixed:
* - Fix FirebaseJson set/remove bugs.
* - Fix zero length string bugs.
*
*
* This library provides ESP8266 to perform REST API by GET PUT, POST, PATCH, DELETE data from/to with Google's Firebase database using get, set, update
Expand Down
2 changes: 1 addition & 1 deletion src/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Firebase Realtime Database Arduino Library for ESP8266


Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.7.0
Google's Firebase Realtime Database Arduino Library for ESP8266 v 2.7.1


## Global functions
Expand Down

0 comments on commit d280545

Please sign in to comment.