]> git.proxmox.com Git - lxcfs.git/blob - debian/patches/0004-cgfs-fix-dorealloc-s-batch-allocation.patch
Add quilt, libpam0g-dev to Build-Depends
[lxcfs.git] / debian / patches / 0004-cgfs-fix-dorealloc-s-batch-allocation.patch
1 From 4d373ffcfee6853662421370fad3df3701573712 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Thu, 7 Jan 2016 12:49:51 +0100
4 Subject: [PATCH lxcfs 4/5] cgfs: fix dorealloc's batch allocation
5
6 The initial check should use real lengths as with modulo a
7 new required length of eg. 52 would be considered smaller
8 than an old length of 48 (2 < 48).
9
10 To get the 'batches' count 'newlen' must be divided and not
11 taken modulo BATCH_SIZE. Otherwise '101', which would need a
12 3rd batch to reach 150, would end up with two (2*50 = 100
13 bytes) and thereby be truncated instead.
14
15 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
16 ---
17 cgfs.c | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-)
19
20 diff --git a/cgfs.c b/cgfs.c
21 index 0659e9e..681a478 100644
22 --- a/cgfs.c
23 +++ b/cgfs.c
24 @@ -75,9 +75,9 @@ static inline void drop_trailing_newlines(char *s)
25 static void dorealloc(char **mem, size_t oldlen, size_t newlen)
26 {
27 int batches;
28 - if (newlen % BATCH_SIZE <= oldlen % BATCH_SIZE)
29 + if (newlen <= oldlen)
30 return;
31 - batches = (newlen % BATCH_SIZE) + 1;
32 + batches = (newlen / BATCH_SIZE) + 1;
33 if (!*mem) {
34 do {
35 *mem = malloc(batches * BATCH_SIZE);
36 --
37 2.1.4
38