Skip to content

Commit f360bdf

Browse files
authored
Removed usage of strcpy to enhance security of the client (#1745)
Removed usage of `strcpy` to enhance security of the client Fixed invalid write in OAUTHBEARER/OIDC extensions copy
1 parent 7905ccb commit f360bdf

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Confluent's Python client for Apache Kafka
22

3+
## v2.4.1
4+
5+
v2.4.1 is a maintenance release with the following fixes and enhancements:
6+
7+
- Removed usage of `strcpy` to enhance security of the client (#1745)
8+
- Fixed invalid write in `OAUTHBEARER/OIDC` extensions copy (#1745)
9+
10+
confluent-kafka-python is based on librdkafka v2.4.1, see the
11+
[librdkafka release notes](https://github.com/confluentinc/librdkafka/releases/tag/v2.4.1)
12+
for a complete list of changes, enhancements, fixes and upgrade considerations.
13+
14+
315
## v2.4.0
416

517
v2.4.0 is a feature release with the following features, fixes and enhancements:

src/confluent_kafka/src/Admin.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,28 @@ Admin_options_to_c (Handle *self, rd_kafka_admin_op_t for_api,
160160
if (Admin_options_is_set_int(options->require_stable_offsets) &&
161161
(err_obj = rd_kafka_AdminOptions_set_require_stable_offsets(
162162
c_options, options->require_stable_offsets))) {
163-
strcpy(errstr, rd_kafka_error_string(err_obj));
163+
snprintf(errstr, sizeof(errstr), "%s", rd_kafka_error_string(err_obj));
164164
goto err;
165165
}
166166

167167
if (Admin_options_is_set_int(options->include_authorized_operations) &&
168168
(err_obj = rd_kafka_AdminOptions_set_include_authorized_operations(
169169
c_options, options->include_authorized_operations))) {
170-
strcpy(errstr, rd_kafka_error_string(err_obj));
170+
snprintf(errstr, sizeof(errstr), "%s", rd_kafka_error_string(err_obj));
171171
goto err;
172172
}
173173

174174
if (Admin_options_is_set_int((int)options->isolation_level) &&
175175
(err_obj = rd_kafka_AdminOptions_set_isolation_level(
176176
c_options,options->isolation_level))) {
177-
strcpy(errstr, rd_kafka_error_string(err_obj));
177+
snprintf(errstr, sizeof(errstr), "%s", rd_kafka_error_string(err_obj));
178178
goto err;
179179
}
180180

181181
if (Admin_options_is_set_ptr(options->states) &&
182182
(err_obj = rd_kafka_AdminOptions_set_match_consumer_group_states(
183183
c_options, options->states, options->states_cnt))) {
184-
strcpy(errstr, rd_kafka_error_string(err_obj));
184+
snprintf(errstr, sizeof(errstr), "%s", rd_kafka_error_string(err_obj));
185185
goto err;
186186
}
187187

src/confluent_kafka/src/confluent_kafka.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,10 +1893,10 @@ static int py_extensions_to_c (char **extensions, Py_ssize_t idx,
18931893
return 0;
18941894
}
18951895

1896-
extensions[idx] = (char*)malloc(ksize);
1897-
strcpy(extensions[idx], k);
1898-
extensions[idx + 1] = (char*)malloc(vsize);
1899-
strcpy(extensions[idx + 1], v);
1896+
extensions[idx] = (char*)malloc(ksize + 1);
1897+
snprintf(extensions[idx], ksize + 1, "%s", k);
1898+
extensions[idx + 1] = (char*)malloc(vsize + 1);
1899+
snprintf(extensions[idx + 1], vsize + 1, "%s", v);
19001900

19011901
Py_DECREF(ks);
19021902
Py_XDECREF(ks8);

0 commit comments

Comments
 (0)