Skip to content

fix: prevent panic in IsDSN on short input strings - #18

Open
SAY-5 wants to merge 1 commit into
vmkteam:masterfrom
SAY-5:fix-isdsn-short-string-panic
Open

fix: prevent panic in IsDSN on short input strings#18
SAY-5 wants to merge 1 commit into
vmkteam:masterfrom
SAY-5:fix-isdsn-short-string-panic

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 26, 2026

Copy link
Copy Markdown

IsDSN guards s[:11] with len(s) > 11 but then evaluates s[:13] without a length check, so any non-DSN argument that is exactly 12 characters (for example pgdesigner docs/apisrv.) panics with slice bounds out of range [:13] with length 12 instead of being treated as a file path.

This switches the two comparisons to strings.HasPrefix, which does its own bounds checking and reads more clearly. Added a table-driven TestIsDSN covering both schemes and the short-string cases.

Fixes #17

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Pgdesigner panics on unfilled file extension

1 participant