Git Product home page Git Product logo

avs_commons's People

Contributors

anuar2k avatar dextero avatar jzimnol avatar kemonats avatar kfyatek avatar kucmasz avatar kylo avatar micholek avatar panekk avatar piotrroszkowski avatar stalowyjez avatar sznaider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

avs_commons's Issues

avs_buffer_create() may allocate excessive amount of memory

Here's why sizeof(struct) - 1 + vla_size shouldn't be used for VLA allocation:

typedef struct {
    long double pad;
    char vla[1];
} Test;

printf("%d\n", (int) (sizeof(Test) - 1));
printf("%d\n", (int) offsetof(Test, vla));

Output (Linux x86_64):

31
16

PKCS7 parsing error using pkcs7_signed_data_parse

Hello,

Using mbedtls, avs_crypto_parse_pkcs7_certs_only fails to parse my PKCS7 file.

Code example here: https://github.com/tfloch/avs_pkcs7_parse_sample

The problem seems to be that it contains multiples "Undefined length" ASN1 tags.

I managed to get the parsing working, using this dirty patch: master...tfloch:avs_commons:parse_pkcs7_with_multiples_indef_length_asn1_tags_workarround

Thank you for your support :)

avs_socket is unusable without a TLS backend enabled

avs_socket.h includes avs_crypto_pki.h which is not installed when all TLS backends are disabled.

Steps to reproduce:

git clone https://github.com/AVSystem/avs_commons
mkdir avs_commons/build
cd avs_commons/build

cmake -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make install
gcc -I $PWD/install/include -x c - <<<"#include <avsystem/commons/avs_socket.h>"   
# compiles fine, linker complains about missing main 

rm -rf ./*

cmake -DWITH_OPENSSL=OFF -DWITH_MBEDTLS=OFF -DWITH_TINYDTLS=OFF -DCMAKE_INSTALL_PREFIX=$PWD/install ..
make install
gcc -I $PWD/install/include -x c - <<<"#include <avsystem/commons/avs_socket.h>"   
# In file included from <stdin>:1:
# /home/dex/projects/avs_commons/build/install/include/avsystem/commons/avs_socket.h:30:10: fatal error: avsystem/commons/avs_crypto_pki.h: No such file or directory
#    30 | #include <avsystem/commons/avs_crypto_pki.h>
#       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# compilation terminated.

An error in FindMbedTLS.cmake

Hi! I'm using your FindMbedTLS.cmake file in my own project. During a makefile generation, I found an error in this file.
Check the line 119:
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDCRYPTO_LIBRARY} ${MBEDX509_LIBRARY})
It must be:
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDTLS_CRYPTO_LIBRARY} ${MBEDTLS_X509_LIBRARY})

Best regards.

Optimizing the avs_url_percent_decode() function

int avs_url_percent_decode(char *data, size_t *unescaped_length) {
char *src = data, *dst = data;
if (!strchr(data, '%')) {
/* nothing to unescape */
*unescaped_length = strlen(data);
return 0;
}
while (*src) {
if (*src == '%') {
if (isxdigit((unsigned char) src[1])
&& isxdigit((unsigned char) src[2])) {

Suggestion:

int avs_url_percent_decode(char *data, size_t *unescaped_length) {
    char *src = data, *dst = data;

    src = strchr(data, '%');
    if (!src) {
        /* nothing to unescape */
        *unescaped_length = strlen(data);
        return 0;
    }

    dst = src;
    while (*src) {
        if (*src == '%') {
            if (isxdigit((unsigned char) src[1])

In the proposed version the while loop starts from % char (if present) and not from the begining as in the original.

For consideration, there is a version with just the while loop without using strchr() and strlen().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.