microsoft / microsoft/Windows-classic-samples

[Win7Sample.OleDb.RowsetViewer] Writing LONG data in SHORT variable

Open
#287 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
5.7k
Forks
3.3k
PR merge metrics
No merged PRs in 30d

Description

VS Debugger found a problem with the following code:

https://github.com/microsoft/Windows-classic-samples/blob/7cbd99ac1d2b4a0beffbaba29ea63d024ceff700/Samples/Win7Samples/dataaccess/oledb/rowsetviewer/crowset.cpp#L671-L672

DBTYPE is based on USHORT datatype.

I have not got any problems with this code within 20 years but I think it needs to correct it with:

				LONG lSchemaType; /*DBTYPE == UI2*/
				if(ConvertToLONG(pwszValue, &lSchemaType, 0/*Min*/, USHRT_MAX, 0/*Base*/))
				{
					//NOTE: on failure we have no choice to leave the column as the original
					//returned integer.
					StringCopy(pwszValue, GetDBTypeName((DBTYPE)lSchemaType), ulMaxSize);
				}

I tested this new code under debugger - it works fine.

Contributor guide

No contributing guide indexed for this repository

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

Start at Samples/Win7Samples/dataaccess/oledb/rowsetviewer/crowset.cpp lines 671-672, where the issue reports DBTYPE conversion. Review the surrounding conversion and string-copy logic, then build or run the RowsetViewer sample under the debugger. Done means the reported type conversion no longer writes LONG data into a SHORT variable and the sample still behaves correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
databases, desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.