summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-11-11 13:53:59 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2024-11-18 21:11:18 +0100
commitb888c66c7244de9b20d174555ffdc22829d6c222 (patch)
tree5179721de1b6683f47802e881f30f580d0b7b7bb /ftparchive
parent963efeff8778afacef35f69c181d234e0a27d5d3 (diff)
ftparchive: override: Remove fixed-size line buffers
LP: #2087848
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/override.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/ftparchive/override.cc b/ftparchive/override.cc
index 02d1566c8..a6768d9d9 100644
--- a/ftparchive/override.cc
+++ b/ftparchive/override.cc
@@ -36,9 +36,10 @@ bool Override::ReadOverride(string const &File,bool const &Source)
if (F == 0)
return _error->Errno("fopen",_("Unable to open %s"),File.c_str());
- char Line[1000];
+ char *Line = nullptr;
+ size_t LineSize = 0;
unsigned long long Counter = 0;
- while (fgets(Line,sizeof(Line),F) != 0)
+ while (getline(&Line, &LineSize, F) != -1)
{
Counter++;
Item Itm;
@@ -124,6 +125,7 @@ bool Override::ReadOverride(string const &File,bool const &Source)
if (ferror(F))
_error->Errno("fgets",_("Failed to read the override file %s"),File.c_str());
+ free(Line);
fclose(F);
return true;
}
@@ -140,9 +142,10 @@ bool Override::ReadExtraOverride(string const &File,bool const &/*Source*/)
if (F == 0)
return _error->Errno("fopen",_("Unable to open %s"),File.c_str());
- char Line[1000];
+ char *Line = nullptr;
+ size_t LineSize = 0;
unsigned long long Counter = 0;
- while (fgets(Line,sizeof(Line),F) != 0)
+ while (getline(&Line, &LineSize, F) != -1)
{
Counter++;
@@ -198,6 +201,7 @@ bool Override::ReadExtraOverride(string const &File,bool const &/*Source*/)
if (ferror(F))
_error->Errno("fgets",_("Failed to read the override file %s"),File.c_str());
+ free(Line);
fclose(F);
return true;
}