Skip to content

CStringChecker.cpp Size argument is greater than the length of the destination buffer #11291

@llvmbot

Description

@llvmbot
Bugzilla Link 10919
Version unspecified
OS Windows XP
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic,@AnnaZaks,@tkremenek

Extended Description

test example:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _XMLNode {
char* tag; /* Tag name */

} XMLNode;

int XML_parse_1string(char* str, XMLNode* xmlnode)
{
int n ,tag_end = 0;
n = 1+tag_end;
xmlnode->tag = (char*)malloc(n - tag_end);
if (xmlnode->tag == NULL) return 0;
strncpy(xmlnode->tag, str+1+tag_end, n-1-tag_end); //it is not a weakness
return 0;
}

this example result a weakness which is "Size argument is greater than the length of the destination buffer", but really it is not a weakness

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions