aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MGA/Advisories.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MGA/Advisories.pm')
-rw-r--r--lib/MGA/Advisories.pm11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index 2506c3c..3752250 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -9,6 +9,7 @@ use DateTime::Format::ISO8601;
use Email::Sender::Simple qw(try_to_sendmail);
use Email::Simple;
use Email::Simple::Creator;
+use Fcntl qw(SEEK_END);
use HTTP::Request;
use LWP::UserAgent;
use Parallel::ForkManager;
@@ -232,6 +233,16 @@ sub assign_id {
return;
}
+ # Appending the ID later assumes that the file ends in a newline
+ open(my $fha, "<", $advfile);
+ seek($fha, -1, SEEK_END);
+ my $c = <$fha>;
+ close($fha);
+ if ($c ne "\n") {
+ print STDERR "$advname missing newline at end of file\n";
+ return;
+ }
+
my $adv = LoadFile($advfile);
if ($adv->{ID}) {
print STDERR "$advname already has an ID assigned: $adv->{ID}\n";