Skip to content

Commit c4d6db0

Browse files
committed
Verify iq->sorese before dereferencing
Signed-off-by: Mark Hannum <[email protected]>
1 parent 8bfef9a commit c4d6db0

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

db/glue.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,19 @@ uint32_t gbl_written_rows_warn = 0;
790790
int64_t gbl_warn_wr_logbytes_per_txn = 1024 * 1024 * 512;
791791
extern int gbl_debug_disttxn_trace;
792792

793+
static void make_tag(struct ireq *iq, char *tag, int taglen)
794+
{
795+
uuidstr_t us;
796+
if (iq->sorese) {
797+
snprintf(tag, taglen, "[%llu:%s]", iq->sorese->rqid, comdb2uuidstr(iq->sorese->uuid, us));
798+
} else if (iq->corigin[0] != '\0') {
799+
snprintf(tag, taglen, "[%s]", iq->corigin);
800+
} else {
801+
snprintf(tag, taglen, "[???]");
802+
}
803+
tag[taglen - 1] = '\0';
804+
}
805+
793806
static int trans_commit_int(struct ireq *iq, void *trans, char *source_host, int timeoutms, int adaptive, int logical,
794807
void *blkseq, int blklen, void *blkkey, int blkkeylen, int release_schema_lk, int nowait)
795808
{
@@ -802,15 +815,14 @@ static int trans_commit_int(struct ireq *iq, void *trans, char *source_host, int
802815
memset(&ss, -1, sizeof(ss));
803816

804817
if (release_schema_lk) {
818+
char tag[1 + 200 + 1] = {0};
805819
if (gbl_written_rows_warn > 0 && iq->written_row_count > gbl_written_rows_warn) {
806-
uuidstr_t us;
807-
logmsg(LOGMSG_USER, "transaction-audit [%llu:%s] modified %u rows\n", iq->sorese->rqid,
808-
comdb2uuidstr(iq->sorese->uuid, us), iq->written_row_count);
820+
make_tag(iq, tag, sizeof(tag));
821+
logmsg(LOGMSG_USER, "transaction-audit %s modified %u rows\n", tag, iq->written_row_count);
809822
}
810823
if (gbl_warn_wr_logbytes_per_txn > 0 && iq->written_logbytes_count > gbl_warn_wr_logbytes_per_txn) {
811-
uuidstr_t us;
812-
logmsg(LOGMSG_USER, "transaction-audit [%llu:%s] wrote %" PRIu64 " logbytes\n", iq->sorese->rqid,
813-
comdb2uuidstr(iq->sorese->uuid, us), iq->written_logbytes_count);
824+
make_tag(iq, tag, sizeof(tag));
825+
logmsg(LOGMSG_USER, "transaction-audit %s wrote %" PRIu64 " logbytes\n", tag, iq->written_logbytes_count);
814826
}
815827
}
816828

0 commit comments

Comments
 (0)