~ubuntu-branches/ubuntu/breezy/koffice/breezy-security

« back to all changes in this revision

Viewing changes to kformula/tests/oasis-kformula.sh

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-10-11 14:49:50 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051011144950-lwpngbifzp8nk0ds
Tags: 1:1.4.1-0ubuntu7
* SECURITY UPDATE: fix heap based buffer overflow in the RTF importer of KWord
* Opening specially crafted RTF files in KWord can cause
  execution of abitrary code.
* Add kubuntu_01_rtfimport_heap_overflow.diff
* References:
  CAN-2005-2971
  CESA-2005-005
  http://www.koffice.org/security/advisory-20051011-1.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
# This script helps finding out problems in the OASIS loading/saving code,
 
4
# by converting .kfo -> .odf -> .kfo and comparing the initial and final .kwd files.
 
5
# We use the kfo format as a "dump" of the KFormula data, to check if everything is correct
 
6
# in memory, but the point is of course to ensure that the .odt has all the information.
 
7
 
 
8
# To use this script, you need to pass the full path to an existing kwd file as argument.
 
9
# Don't use a relative path, dcopstart won't handle it
 
10
input="$1"
 
11
 
 
12
# Set this to 1 in order to validate the saved oasis document using oasislint
 
13
checkoasis="1"
 
14
 
 
15
appname=kformula
 
16
oldextension=kfo
 
17
oasisextension=odf
 
18
oasismimetype=application/vnd.oasis.opendocument.formula
 
19
 
 
20
test -f "$input" || { echo "No such file $input"; exit 1; }
 
21
 
 
22
# Load old native file
 
23
appid=`dcopstart $appname $input`
 
24
test -n "$appid" || { echo "Error starting $appname!"; exit 1; }
 
25
while `dcop $appid Document-0 isLoading` == "true"; do
 
26
    sleep 1;
 
27
done
 
28
 
 
29
# Save again (in case of changes in syntax etc.)
 
30
origfile=$PWD/oasisregtest-initial.$oldextension
 
31
dcop $appid Document-0 saveAs $origfile || exit 1
 
32
test -f $origfile || exit 1
 
33
 
 
34
# Save to OASIS
 
35
tmpoasisfile=$PWD/oasisregtest.$oasisextension
 
36
dcop $appid Document-0 setOutputMimeType $oasismimetype || exit 1
 
37
dcop $appid Document-0 saveAs $tmpoasisfile || exit 1
 
38
test -f $tmpoasisfile || exit 1
 
39
 
 
40
dcopquit $appid
 
41
 
 
42
# Load resulting OASIS file, convert to old native format
 
43
tmpnativefile=$PWD/oasisregtest-final.$oldextension
 
44
appid=`dcopstart $appname $tmpoasisfile`
 
45
while `dcop $appid Document-0 isLoading` == "true"; do
 
46
    sleep 1;
 
47
done
 
48
dcop $appid Document-0 setOutputMimeType "application/x-$appname" || exit 1
 
49
dcop $appid Document-0 saveAs $tmpnativefile || exit 1
 
50
test -f $tmpnativefile || exit 1
 
51
 
 
52
# Unpack everything
 
53
rm -rf oasisregtest-orig
 
54
mkdir oasisregtest-orig
 
55
rm -rf oasisregtest-final
 
56
mkdir oasisregtest-final
 
57
rm -rf oasisregtest-oasis
 
58
mkdir oasisregtest-oasis
 
59
cd oasisregtest-orig || exit 1
 
60
unzip $origfile || exit 1
 
61
cd ..
 
62
cd oasisregtest-final || exit 1
 
63
unzip $tmpnativefile || exit 1
 
64
cd ..
 
65
# Validate OASIS format
 
66
cd oasisregtest-oasis || exit 1
 
67
unzip $tmpoasisfile || exit 1
 
68
if test "$checkoasis" = "1"; then
 
69
  if type -p oasislint >/dev/null 2>&1; then
 
70
    for f in content.xml styles.xml meta.xml settings.xml; do
 
71
      echo "Checking $f..." ; oasislint $f 
 
72
    done
 
73
  fi
 
74
  if type -p oasislint-strict >/dev/null 2>&1; then
 
75
    for f in content.xml styles.xml meta.xml settings.xml; do
 
76
      echo "Checking $f strict..." && oasislint-strict $f
 
77
    done
 
78
  fi
 
79
fi
 
80
cd ..
 
81
 
 
82
# Compare initial and final "native format" files
 
83
diff -urp oasisregtest-orig oasisregtest-final 2>&1 | tee oasisdiff | less
 
84
 
 
85
echo "See oasisregtest-oasis for the OASIS xml files."
 
86
echo "For a better diffing mechanism, launch xemacs and paste into a terminal:"
 
87
echo "gnudoit '(ediff-files \"$PWD/oasisregtest-orig/maindoc.xml\" \"$PWD/oasisregtest-final/maindoc.xml\")'"