if (found) {
size_t userinfo_len = strlen(proxy_uri) - strlen(found);
char *userinfo = strndup(proxy_uri, userinfo_len);
+ if (!userinfo) {
+ DA_LOGE("Failed to copy proxy_uri to userinfo");
+ free(proxy_info);
+ free(proxy_uri);
+ return DA_NULL;
+ }
+
if (strstr(userinfo, SCHEME_DELIMETER))
sscanf(userinfo, "%7[^:/]://%255[^:]:%255s", scheme, user_name, password);
else
if (getbytes > 0) {
unsigned char *getstr = (unsigned char *)calloc(getbytes + 1, sizeof(unsigned char));
if (getstr != NULL) {
- memcpy(getstr, sqlite3_column_text(stmt, 0), getbytes * sizeof(unsigned char));
- getstr[getbytes] = '\0';
- *value = getstr;
- *length = getbytes;
+ const unsigned char *txt = sqlite3_column_text(stmt, 0);
+ if (txt) {
+ memcpy(getstr, txt, getbytes * sizeof(unsigned char));
+ getstr[getbytes] = '\0';
+ *value = getstr;
+ *length = getbytes;
+ } else {
+ TRACE_ERROR("sqlite3_column_txt() returns NULL");
+ *error = DP_ERROR_NO_DATA;
+ }
} else {
TRACE_ERROR("check available system memory");
*error = DP_ERROR_OUT_OF_MEMORY;
if (getbytes > 0) {
unsigned char *getstr = (unsigned char *)calloc(getbytes, sizeof(unsigned char));
if (getstr != NULL) {
- memcpy(getstr, sqlite3_column_blob(stmt, 0), getbytes * sizeof(unsigned char));
- *value = getstr;
- *length = getbytes;
+ const void *blob = sqlite3_column_blob(stmt, 0);
+ if (blob) {
+ memcpy(getstr, blob, getbytes * sizeof(unsigned char));
+ *value = getstr;
+ *length = getbytes;
+ } else {
+ TRACE_ERROR("sqlite3_column_blob() returns NULL");
+ *error = DP_ERROR_OUT_OF_MEMORY;
+ }
} else {
TRACE_ERROR("check available system memory");
*error = DP_ERROR_OUT_OF_MEMORY;