nickva commented on code in PR #4262:
URL: https://github.com/apache/couchdb/pull/4262#discussion_r1048934999
##########
src/couch/priv/couch_js/86/util.cpp:
##########
@@ -26,6 +26,29 @@
#include "help.h"
#include "util.h"
+const char*
+get_spidermonkey_version() {
+ const char *JAVASCRIPT = "JavaScript-C";
+ int js_len = strlen(JAVASCRIPT);
+
+ // JS_GetImplementationVersion()
+ // returns "JavaScript-CMAJOR.MINOR.PATCH"
+ const char *FULLVERSION = JS_GetImplementationVersion();
+ int fv_len = strlen(FULLVERSION);
+
+ const char* foundJSString = strstr(FULLVERSION,JAVASCRIPT);
+ if (foundJSString != NULL) {
+ //trim off "JavaScript-C",
+ char *buf = (char*) calloc(fv_len - js_len + 1, sizeof(char));
+ strncpy(buf, &FULLVERSION[js_len], fv_len - js_len);
+ buf[fv_len - js_len + 1] = '\0';
Review Comment:
If we allocate N bytes with calloc and write at buf[N] this would write over
the boundary?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]