瀏覽代碼

Replace snprintf() with xstrlcpy()

master
Arun Prakash Jana 7 年之前
父節點
當前提交
e6580c38bf
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: A75979F35C080412
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. +8
    -6
      nnn.c

+ 8
- 6
nnn.c 查看文件

@@ -342,8 +342,7 @@ crc8fast(uchar const message[], size_t n)
}

/* The final remainder is the CRC */
return (remainder);

return remainder;
}

/* Messages show up at the bottom */
@@ -1230,23 +1229,26 @@ readinput(void)

/*
* Updates out with "dir/name or "/name"
* Returns the number of bytes in out including the terminating NULL byte
* Returns the number of bytes copied including the terminating NULL byte
*/
size_t
mkpath(char *dir, char *name, char *out, size_t n)
{
static size_t len;

/* Handle absolute path */
if (name[0] == '/')
return xstrlcpy(out, name, n);
else {
/* Handle root case */
if (istopdir(dir))
return (snprintf(out, n, "/%s", name) + 1);
len = 1;
else
return (snprintf(out, n, "%s/%s", dir, name) + 1);
len = xstrlcpy(out, dir, n);
}

return 0;
out[len - 1] = '/';
return (xstrlcpy(out + len, name, n - len) + len);
}

static void


||||||
x
 
000:0
Loading…
取消
儲存