[BACK]Return to sshbuf.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sshbuf.c between version 1.16 and 1.17

version 1.16, 2022/04/08 04:40:40 version 1.17, 2022/05/25 00:31:13
Line 39 
Line 39 
             buf->size > buf->alloc ||              buf->size > buf->alloc ||
             buf->off > buf->size)) {              buf->off > buf->size)) {
                 /* Do not try to recover from corrupted buffer internals */                  /* Do not try to recover from corrupted buffer internals */
                 SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));                  SSHBUF_DBG("SSH_ERR_INTERNAL_ERROR");
                 ssh_signal(SIGSEGV, SIG_DFL);                  ssh_signal(SIGSEGV, SIG_DFL);
                 raise(SIGSEGV);                  raise(SIGSEGV);
                 return SSH_ERR_INTERNAL_ERROR;                  return SSH_ERR_INTERNAL_ERROR;
Line 50 
Line 50 
 static void  static void
 sshbuf_maybe_pack(struct sshbuf *buf, int force)  sshbuf_maybe_pack(struct sshbuf *buf, int force)
 {  {
         SSHBUF_DBG(("force %d", force));          SSHBUF_DBG("force %d", force);
         SSHBUF_TELL("pre-pack");          SSHBUF_TELL("pre-pack");
         if (buf->off == 0 || buf->readonly || buf->refcount > 1)          if (buf->off == 0 || buf->readonly || buf->refcount > 1)
                 return;                  return;
Line 221 
Line 221 
         u_char *dp;          u_char *dp;
         int r;          int r;
   
         SSHBUF_DBG(("set max buf = %p len = %zu", buf, max_size));          SSHBUF_DBG("set max buf = %p len = %zu", buf, max_size);
         if ((r = sshbuf_check_sanity(buf)) != 0)          if ((r = sshbuf_check_sanity(buf)) != 0)
                 return r;                  return r;
         if (max_size == buf->max_size)          if (max_size == buf->max_size)
Line 239 
Line 239 
                         rlen = ROUNDUP(buf->size, SSHBUF_SIZE_INC);                          rlen = ROUNDUP(buf->size, SSHBUF_SIZE_INC);
                 if (rlen > max_size)                  if (rlen > max_size)
                         rlen = max_size;                          rlen = max_size;
                 SSHBUF_DBG(("new alloc = %zu", rlen));                  SSHBUF_DBG("new alloc = %zu", rlen);
                 if ((dp = recallocarray(buf->d, buf->alloc, rlen, 1)) == NULL)                  if ((dp = recallocarray(buf->d, buf->alloc, rlen, 1)) == NULL)
                         return SSH_ERR_ALLOC_FAIL;                          return SSH_ERR_ALLOC_FAIL;
                 buf->cd = buf->d = dp;                  buf->cd = buf->d = dp;
Line 307 
Line 307 
         u_char *dp;          u_char *dp;
         int r;          int r;
   
         SSHBUF_DBG(("allocate buf = %p len = %zu", buf, len));          SSHBUF_DBG("allocate buf = %p len = %zu", buf, len);
         if ((r = sshbuf_check_reserve(buf, len)) != 0)          if ((r = sshbuf_check_reserve(buf, len)) != 0)
                 return r;                  return r;
         /*          /*
Line 325 
Line 325 
          */           */
         need = len + buf->size - buf->alloc;          need = len + buf->size - buf->alloc;
         rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);          rlen = ROUNDUP(buf->alloc + need, SSHBUF_SIZE_INC);
         SSHBUF_DBG(("need %zu initial rlen %zu", need, rlen));          SSHBUF_DBG("need %zu initial rlen %zu", need, rlen);
         if (rlen > buf->max_size)          if (rlen > buf->max_size)
                 rlen = buf->alloc + need;                  rlen = buf->alloc + need;
         SSHBUF_DBG(("adjusted rlen %zu", rlen));          SSHBUF_DBG("adjusted rlen %zu", rlen);
         if ((dp = recallocarray(buf->d, buf->alloc, rlen, 1)) == NULL) {          if ((dp = recallocarray(buf->d, buf->alloc, rlen, 1)) == NULL) {
                 SSHBUF_DBG(("realloc fail"));                  SSHBUF_DBG("realloc fail");
                 return SSH_ERR_ALLOC_FAIL;                  return SSH_ERR_ALLOC_FAIL;
         }          }
         buf->alloc = rlen;          buf->alloc = rlen;
Line 352 
Line 352 
         if (dpp != NULL)          if (dpp != NULL)
                 *dpp = NULL;                  *dpp = NULL;
   
         SSHBUF_DBG(("reserve buf = %p len = %zu", buf, len));          SSHBUF_DBG("reserve buf = %p len = %zu", buf, len);
         if ((r = sshbuf_allocate(buf, len)) != 0)          if ((r = sshbuf_allocate(buf, len)) != 0)
                 return r;                  return r;
   
Line 368 
Line 368 
 {  {
         int r;          int r;
   
         SSHBUF_DBG(("len = %zu", len));          SSHBUF_DBG("len = %zu", len);
         if ((r = sshbuf_check_sanity(buf)) != 0)          if ((r = sshbuf_check_sanity(buf)) != 0)
                 return r;                  return r;
         if (len == 0)          if (len == 0)
Line 388 
Line 388 
 {  {
         int r;          int r;
   
         SSHBUF_DBG(("len = %zu", len));          SSHBUF_DBG("len = %zu", len);
         if ((r = sshbuf_check_sanity(buf)) != 0)          if ((r = sshbuf_check_sanity(buf)) != 0)
                 return r;                  return r;
         if (len == 0)          if (len == 0)

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17