Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bounds checking to prevent overflow warnings during build. #105

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

ciaran-moore
Copy link

Added bounds checking to util/src/inet.cpp to prevent overflow warnings during build.

Received the following warnings on Debian 12 when installing with the build command: cmake --preset Release -DPHP_SCYLLADB_OPTIMISE_FOR_CURRENT_MACHINE=ON -DPHP_SCYLLADB_USE_LIBCASSANDRA=ON -DPHP_SCYLLADB_LIBUV_STATIC=ON && cd out/Release && sudo ninja install

-- Build files have been written to: /home/dev/scylladb-php-driver/out/Release
[166/167] Linking CXX shared library cassandra.so
/home/dev/scylladb-php-driver/util/src/inet.cpp: In function ‘php_driver_parse_ip_address’:
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483663, -1] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
      |                ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483648, -2] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
      |                ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483648, -3] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
      |                ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483648, -4] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
      |                ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483648, -5] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
      |                ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483648, -6] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
      |                ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:383:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  383 |         address[src_pos] = 0;
      |                          ^
/home/dev/scylladb-php-driver/util/src/inet.cpp:132:16: note: at offset [-2147483648, -1] into destination object ‘address’ of size 16
  132 |   cass_uint8_t address[CASS_INET_V6_LENGTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

@CodeLieutenant
Copy link
Member

Thanks, looks good!

@CodeLieutenant CodeLieutenant merged commit a861c1b into he4rt:v1.3.x Sep 18, 2024
1 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants