Skip to content

Commit

Permalink
fuck backward compatability - snprintf for the win
Browse files Browse the repository at this point in the history
  • Loading branch information
vanhauser-thc committed May 21, 2020
1 parent 609201f commit c426452
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sasl.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,10 @@ char *sasl_digest_md5(char *result, char *login, char *pass, char *buffer, char
sprintf(pbuffer, "%02x", response[i]);
pbuffer += 2;
}
sprintf(buffer, "%s:%s:%s", buffer3, nonce, "hydra");
snprintf(buffer, 500, "%s:%s:%s", buffer3, nonce, "hydra");
} else {
memcpy(buffer, response, sizeof(response));
sprintf(buffer + sizeof(response), ":%s:%s", nonce, "hydra");
snprintf(buffer + sizeof(response), 50 - sizeof(response), ":%s:%s", nonce, "hydra");
}
MD5_Init(&md5c);
MD5_Update(&md5c, buffer, strlen(buffer));
Expand All @@ -479,22 +479,22 @@ char *sasl_digest_md5(char *result, char *login, char *pass, char *buffer, char
// compute ha2
// proxy case
if (strstr(type, "proxy") != NULL)
sprintf(buffer, "%s:%s", "HEAD", miscptr);
snprintf(buffer, 500, "%s:%s", "HEAD", miscptr);
else
// http case
if ((strstr(type, "GET") != NULL) || (strstr(type, "HEAD") != NULL))
sprintf(buffer, "%s:%s", type, miscptr);
snprintf(buffer, 500, "%s:%s", type, miscptr);
else
// sip case
if (strstr(type, "sip") != NULL)
sprintf(buffer, "REGISTER:%s:%s", type, miscptr);
snprintf(buffer, 500, "REGISTER:%s:%s", type, miscptr);
else
// others
if (strstr(type, "rtsp") != NULL)
sprintf(buffer, "DESCRIBE:%s://%s:%i", type, webtarget, port);
snprintf(buffer, 500, "DESCRIBE:%s://%s:%i", type, webtarget, port);
else
// others
sprintf(buffer, "AUTHENTICATE:%s/%s", type, realm);
snprintf(buffer, 500, "AUTHENTICATE:%s/%s", type, realm);

MD5_Init(&md5c);
MD5_Update(&md5c, buffer, strlen(buffer));
Expand Down

1 comment on commit c426452

@fe1yu7
Copy link

@fe1yu7 fe1yu7 commented on c426452 Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

Please sign in to comment.