Skip to content

Commit

Permalink
secgsi: initialize output buffers in Encrypt/Decrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
gganis committed Oct 10, 2016
1 parent 7d9f033 commit a0c839a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/XrdSecgsi/XrdSecProtocolgsi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,10 @@ int XrdSecProtocolgsi::Encrypt(const char *inbuf, // Data to be encrypted
return -EINVAL;

// Get output buffer
char *buf = (char *)malloc(sessionKey->EncOutLength(inlen));
if (!buf)
return -ENOMEM;
int sz = sessionKey->EncOutLength(inlen);
char *buf = (char *)malloc(sz);
if (!buf) return -ENOMEM;
memset(buf, 0, sz);

// Encrypt
int len = sessionKey->Encrypt(inbuf, inlen, buf);
Expand Down Expand Up @@ -1109,9 +1110,10 @@ int XrdSecProtocolgsi::Decrypt(const char *inbuf, // Data to be decrypted
return -EINVAL;

// Get output buffer
char *buf = (char *)malloc(sessionKey->DecOutLength(inlen));
if (!buf)
return -ENOMEM;
int sz = sessionKey->DecOutLength(inlen);
char *buf = (char *)malloc(sz);
if (!buf) return -ENOMEM;
memset(buf, 0, sz);

// Decrypt
int len = sessionKey->Decrypt(inbuf, inlen, buf);
Expand Down

0 comments on commit a0c839a

Please sign in to comment.