oracle / oracle/dtrace

dt_cg_store_var() needs to copy terminating NUL byte for strings

Open
#57 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
189
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Consider
/*
* Determine the amount of data to be copied. It is
* the lesser of the size of the identifier and the
* size of the data being copied in.
*/
srcsz = dt_node_type_size(dnp->dn_right);
if (dt_node_is_string(dnp))
srcsz += DT_STRLEN_BYTES;
size = MIN(srcsz, size);

"srcsz = dt_node_type_size(dnp->dn_right)" includes the terminating NUL byte for string constants but not for regular string types.

"size = idp->di_size" generally will not include the NUL terminating byte either.

Check and fix this code on both the gvar/lvar and the tvar code paths.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search for dt_cg_store_var() and inspect the gvar/lvar and tvar code paths around srcsz, size, and DT_STRLEN_BYTES. Verify how string sizes are calculated and ensure both paths account for the terminating NUL byte when copying. Done means the behavior is corrected consistently for both paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.