avoid exceptions by rename vars in getpart.c

This commit is contained in:
Viktor Szakats 2025-07-12 09:49:09 +02:00
parent cb056a7ee1
commit 7cdd186798
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
3 changed files with 17 additions and 18 deletions

View file

@ -8,7 +8,6 @@ ba
bu
clen
CNA
couter
dout
ede
fo

View file

@ -6,6 +6,6 @@
extend-ignore-identifiers-re = [
"[A-Za-z]{2,3}",
"(admi|alue|CLEA|clen|dout|inex|HELO|helo|htpt|PARM|parm|PASE)",
"(couter|HEADE|numer|optin|parms|stati|ttests)",
"(HEADE|numer|optin|parms|stati|ttests)",
"(Januar|passin|Passiv|perfec|PUNICODE|TEMPLAT|varius)",
]

View file

@ -244,11 +244,11 @@ int getpart(char **outbuf, size_t *outlen,
const char *main, const char *sub, FILE *stream)
{
# define MAX_TAG_LEN 200
char couter[MAX_TAG_LEN + 1]; /* current outermost section */
char cmain[MAX_TAG_LEN + 1]; /* current main section */
char csub[MAX_TAG_LEN + 1]; /* current sub section */
char ptag[MAX_TAG_LEN + 1]; /* potential tag */
char patt[MAX_TAG_LEN + 1]; /* potential attributes */
char cur_outer[MAX_TAG_LEN + 1]; /* current outermost section */
char cur_main[MAX_TAG_LEN + 1]; /* current main section */
char cur_sub[MAX_TAG_LEN + 1]; /* current sub section */
char ptag[MAX_TAG_LEN + 1]; /* potential tag */
char patt[MAX_TAG_LEN + 1]; /* potential attributes */
char *buffer = NULL;
char *ptr;
char *end;
@ -278,7 +278,7 @@ int getpart(char **outbuf, size_t *outlen,
return GPE_OUT_OF_MEMORY;
*(*outbuf) = '\0';
couter[0] = cmain[0] = csub[0] = ptag[0] = patt[0] = '\0';
cur_outer[0] = cur_main[0] = cur_sub[0] = ptag[0] = patt[0] = '\0';
while((error = readline(&buffer, &bufsize, &datalen, stream)) == GPE_OK) {
@ -314,10 +314,10 @@ int getpart(char **outbuf, size_t *outlen,
memcpy(ptag, ptr, len.uns);
ptag[len.uns] = '\0';
if((STATE_INSUB == state) && !strcmp(csub, ptag)) {
if((STATE_INSUB == state) && !strcmp(cur_sub, ptag)) {
/* end of current sub section */
state = STATE_INMAIN;
csub[0] = '\0';
cur_sub[0] = '\0';
if(in_wanted_part) {
/* Do we need to base64 decode the data? */
if(base64) {
@ -330,10 +330,10 @@ int getpart(char **outbuf, size_t *outlen,
break;
}
}
else if((STATE_INMAIN == state) && !strcmp(cmain, ptag)) {
else if((STATE_INMAIN == state) && !strcmp(cur_main, ptag)) {
/* end of current main section */
state = STATE_OUTER;
cmain[0] = '\0';
cur_main[0] = '\0';
if(in_wanted_part) {
/* Do we need to base64 decode the data? */
if(base64) {
@ -346,10 +346,10 @@ int getpart(char **outbuf, size_t *outlen,
break;
}
}
else if((STATE_OUTER == state) && !strcmp(couter, ptag)) {
else if((STATE_OUTER == state) && !strcmp(cur_outer, ptag)) {
/* end of outermost file section */
state = STATE_OUTSIDE;
couter[0] = '\0';
cur_outer[0] = '\0';
if(in_wanted_part)
break;
}
@ -393,21 +393,21 @@ int getpart(char **outbuf, size_t *outlen,
if(STATE_OUTSIDE == state) {
/* outermost element (<testcase>) */
strcpy(couter, ptag);
strcpy(cur_outer, ptag);
state = STATE_OUTER;
continue;
}
else if(STATE_OUTER == state) {
/* start of a main section */
strcpy(cmain, ptag);
strcpy(cur_main, ptag);
state = STATE_INMAIN;
continue;
}
else if(STATE_INMAIN == state) {
/* start of a sub section */
strcpy(csub, ptag);
strcpy(cur_sub, ptag);
state = STATE_INSUB;
if(!strcmp(cmain, main) && !strcmp(csub, sub)) {
if(!strcmp(cur_main, main) && !strcmp(cur_sub, sub)) {
/* start of wanted part */
in_wanted_part = 1;
if(strstr(patt, "base64="))