summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-06-19 07:43:56 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-09-02 18:11:01 +0200
commit578b3317af12be7c5ecedd8240c09a3d513fa382 (patch)
tree7788c5cf0ee603b67f95baffe8657aa702e62c03
parenta34199684bb1e59e56c3bc5f30881a5402ebe7b9 (diff)
downloadpython-apt-578b3317af12be7c5ecedd8240c09a3d513fa382.tar.gz
python/tag.cc: ensure that the final \n is there when duplicating section data
-rw-r--r--python/tag.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/python/tag.cc b/python/tag.cc
index 50786cee..8f483467 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -338,11 +338,14 @@ static PyObject *TagFileNext(PyObject *Self)
const char *Start;
const char *Stop;
Obj.Section->Object.GetSection(Start,Stop);
- // Duplicate the data
- Obj.Section->Data = new char[Stop-Start];
- strncpy(Obj.Section->Data, Start, Stop-Start);
+ // Duplicate the data and
+ // append a \n because GetSection() will only give us a single \n
+ // but Scan() needs \n\n to work
+ Obj.Section->Data = new char[Stop-Start+2];
+ snprintf(Obj.Section->Data, Stop-Start+2, "%s\n", Start);
// Rescan it
- Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start);
+ if(Obj.Section->Object.Scan(Obj.Section->Data, Stop-Start) == false)
+ return HandleErrors(NULL);
Py_INCREF(Obj.Section);
return HandleErrors(Obj.Section);