Comments (4)
Is text pre-allocatable? I guess not, since the caller can not predict how long a string will be.
The current implementation of jsonRpc_handleReply
is confusing in this regard.
if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
void *tmp = NULL;
void **out = (void **) args[i];
size_t size = 0;
if (dynType_descriptorType(argType) == 't') {
status = jsonSerializer_deserializeJson(argType, result, &tmp);
if (tmp != NULL) {
size = strnlen(((char *) *(char**) tmp), 1024 * 1024);
memcpy(*out, *(void**) tmp, size);
}
} else {
dynType_typedPointer_getTypedType(argType, &argType);
status = jsonSerializer_deserializeJson(argType, result, &tmp);
if (tmp != NULL) {
size = dynType_size(argType);
memcpy(*out, tmp, size);
}
}
How could the caller of the remote method to know the resulting strnlen
so that he/she can allocate buffer large enough?
I feel that the precise definitions of these types are needed at the moment to have a solid RSA implementation. @pnoltes
from celix.
I try to give the following definitions:
Standard argument should be serializable. All types except types involving untyped pointer or double pointer (pointer to pointer) are serializable. For example, complex types consisting of non-pointer fields are serializable while complex type containing a untyped pointer field is not serializable; [I
is serializable while [P
and [**D
are not serializable.
am=out
parameter should be pointer to text or double pointer to serializable types.
am=pre
parameter should be pointer to trivially copyable type. It's safe to apply memcpy
rivially copyable type without the usual danger of shallow copy. However, this definition is only meant to make the following code work:
if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
void *tmp = NULL;
void **out = (void **) args[i];
size_t size = 0;
dynType_typedPointer_getTypedType(argType, &argType);
status = jsonSerializer_deserializeJson(argType, result, &tmp);
if (tmp != NULL) {
size = dynType_size(argType);
memcpy(*out, tmp, size);
}
dynType_free(argType, tmp);
By this definition, [D
can not be used as am=pre
, because dynType_free(argType, tmp)
will free the embedded buffer, which has been copied to *out
(thus lead to use-after-free). I think the main usage of SequenceType is to be used as pre-allocated output paramter and let the callee to fill in actual content. Thus this definition will make SequenceType useless.
Any ideas to make am=pre
work? @pnoltes
The above reflects my understanding of the current code base, which may deviate from the original intention. Please shed light on this, any help will be appreciated.
PS: Maybe SequenceType does not qualify as am=pre
, because it is essentially a inout parameter (currently unsupported), whose capacity must be serialized and sent to the provider end.
from celix.
Sorry for the late reaction.
Any ideas to make
am=pre
work? @pnoltesThe above reflects my understanding of the current code base, which may deviate from the original intention. Please shed light on this, any help will be appreciated.
My original idea for the am=pre was to support primitive types (double, bool, ec) and indeed trivially trivially copyable type.
I agree that this should be made more explicit and the parse of dfi can test if the am=pre argument fits the requirements. If needed this can be extended in the future.
So IMO no am=pre support for pointer in structs, double pointers, strings or sequences.
from celix.
Is like the dynType_isPreallocatable
approach :)
from celix.
Related Issues (20)
- Framework statistics
- Clarify and improve parsing of the .properties file format HOT 2
- Error Handling and Coverage Improvement of the Framework Library
- Shell command support as consumerbundle HOT 8
- Bundle Management API Usability Improvement HOT 3
- CXX Remote Service stack-uffer-underflow
- Ensure the build containers keeps working
- Annotation of Consumer/Provider Type HOT 1
- celix 2.4.0 installation problem HOT 3
- macOS Build Timeout HOT 3
- How to debug bundles with GDB HOT 9
- Use-after-free in RemoteServicesIntegrationTestSuite.InvokeRemoteCalcService HOT 1
- Self-Contained Apache Celix Executable for Simplified Installation and Deployment1 HOT 1
- Minimize over-inclusion to reduce accidental complexity in header files HOT 1
- Discovery Zeroconf Portability
- General Dynamic IP Resolution for RSA
- Unified Error Codes for libdfi
- Memory Leaks Caused By realloc Failure
- Unlimited Spin of Glibc's Read-write-lock Implementation HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from celix.