Ticket #10226: 0001-Fixed-resource-leak-and-possible-strings-without-nul.patch

File 0001-Fixed-resource-leak-and-possible-strings-without-nul.patch, 2.0 KB (added by Ezodev, 6 years ago)
  • src/system/kernel/vm/VMAnonymousCache.cpp

    From f2c98c551bfe50a155bf73a01affa8a5350e2782 Mon Sep 17 00:00:00 2001
    From: Ezo <ezo.dev@gmail.com>
    Date: Wed, 20 Nov 2013 07:00:17 +0000
    Subject: [PATCH] Fixed resource leak and possible strings without
     null-terminator
    
    ---
     src/system/kernel/vm/VMAnonymousCache.cpp | 12 +++++++++---
     1 file changed, 9 insertions(+), 3 deletions(-)
    
    diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp
    index d0337ba..558ea26 100644
    a b swap_init_post_modules()  
    14521452    dev_t swapDeviceID = -1;
    14531453    VolumeInfo selectedVolume = {};
    14541454
     1455    bool settingsUnloaded = false;
    14551456    void* settings = load_driver_settings("virtual_memory");
    14561457
    14571458    if (settings != NULL) {
    swap_init_post_modules()  
    14841485                    // User specified a size / volume that seems valid
    14851486                    swapAutomatic = false;
    14861487                    swapSize = atoll(size);
    1487                     strncpy(selectedVolume.name, volume,
     1488                    strlcpy(selectedVolume.name, volume,
    14881489                        sizeof(selectedVolume.name));
    1489                     strncpy(selectedVolume.device, device,
     1490                    strlcpy(selectedVolume.device, device,
    14901491                        sizeof(selectedVolume.device));
    1491                     strncpy(selectedVolume.filesystem, filesystem,
     1492                    strlcpy(selectedVolume.filesystem, filesystem,
    14921493                        sizeof(selectedVolume.filesystem));
    14931494                    selectedVolume.capacity = atoll(capacity);
    14941495                } else {
    swap_init_post_modules()  
    14991500                }
    15001501            }
    15011502            unload_driver_settings(settings);
     1503            settingsUnloaded = true;
    15021504        }
    15031505    }
    15041506
    swap_init_post_modules()  
    15141516
    15151517    if (!swapEnabled || swapSize < B_PAGE_SIZE) {
    15161518        dprintf("%s: virtual_memory is disabled\n", __func__);
     1519        if(!settingsUnloaded)
     1520            unload_driver_settings(settings);
    15171521        return;
    15181522    }
    15191523
    swap_init_post_modules()  
    15931597    if (fd < 0) {
    15941598        dprintf("%s: Can't open/create %s: %s\n", __func__,
    15951599            swapPath, strerror(errno));
     1600        if(!settingsUnloaded)
     1601            unload_driver_settings(settings);
    15961602        return;
    15971603    }
    15981604