Skip to content
Back to skills

Detecting Incorrect Memset

ASecurity

Detects incorrect use of memset() including wrong argument order, incorrect size calculations, and misunderstood behavior. Use when analyzing memory initialization, buffer clearing, or investigating memset() usage errors.

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
businesssecurity

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill detecting-incorrect-memset --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Detecting Incorrect Memset?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Detecting Incorrect Memset
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-detecting-incorrect-memset/badge)](https://www.skillsdirectory.com/skills/majiayu000-detecting-incorrect-memset)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: detecting-incorrect-memset
description: Detects incorrect use of memset() including wrong argument order, incorrect size calculations, and misunderstood behavior. Use when analyzing memory initialization, buffer clearing, or investigating memset() usage errors.
---

# Incorrect Use of Memset Detection

## Detection Workflow

1. **Identify memset operations**: Find all memset() calls, locate buffer clearing operations, identify memory initialization, map sensitive data handling
2. **Analyze argument order**: Verify memset argument order, check pointer/value/size order, assess argument correctness, review common mistakes
3. **Check size calculation**: Verify size parameter, check sizeof usage, assess size correctness, review buffer dimensions
4. **Assess security impact**: Does incorrect memset leave data? Is sensitive data exposed? Can compiler optimize away memset? What's the security impact?

## Key Patterns

- Wrong argument order: memset with wrong argument order, size and value arguments swapped, pointer and size arguments swapped, common memset mistakes
- Incorrect size calculation: sizeof on pointer instead of buffer, off-by-one errors in size, size calculation with overflow, wrong size for buffer type
- Misunderstood memset behavior: expecting memset to return filled value, assuming memset validates arguments, thinking memset checks for NULL, misunderstanding memset return value
- Ineffective clearing: memset on optimized-away variables, compiler removing memset calls, incomplete buffer clearing, missing memset on sensitive data

## Output Format

Report with: id, type, subtype, severity, confidence, location, vulnerability, memset_call, correct_order, arguments, actual_operation, expected_operation, exploitable, attack_scenario, impact, mitigation.

## Severity Guidelines

- **HIGH**: Incorrect memset leaving sensitive data
- **MEDIUM**: Incorrect memset causing memory corruption
- **LOW**: Minor memset errors

## See Also

- `patterns.md` - Detailed detection patterns and exploitation scenarios
- `examples.md` - Example analysis cases and code samples
- `references.md` - CWE references and mitigation strategies

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.