aboutsummaryrefslogtreecommitdiff
path: root/firma
diff options
context:
space:
mode:
authorluis <luis>2005-08-23 16:57:20 +0000
committerluis <luis>2005-08-23 16:57:20 +0000
commit3525012cf157849ce8b227220571a83aa1c37688 (patch)
treef3ed57bef0f074158641003e02333b7e708fe5a8 /firma
parent137d46090a787f5992a3114a1e3782c113b5facf (diff)
downloadfirma-3525012cf157849ce8b227220571a83aa1c37688.tar.gz
firma-3525012cf157849ce8b227220571a83aa1c37688.tar.bz2
Fixed a possible infinite loop on function GetMessageHeaders and made some minor changes to variable DATE.
Diffstat (limited to 'firma')
-rwxr-xr-xfirma29
1 files changed, 16 insertions, 13 deletions
diff --git a/firma b/firma
index 1684396..0881dba 100755
--- a/firma
+++ b/firma
@@ -198,28 +198,31 @@ function GetMessageHeaders {
#-------------------------------------------------------------
local element
+ local first_blank_line
- # store all headers in array ORIG_MESSAGE_HEADERS
+ # find the first blank line in the message
for element in $(seq 0 $((${#ORIG_MESSAGE[@]} - 1))); do
- until [[ "${ORIG_MESSAGE[$element]}" == "\n" ]]; do
- ORIG_MESSAGE_HEADERS[$element]="${ORIG_MESSAGE[$element]}"
- ((++element))
- done
- # done, reached first blank line in message
- # exit for loop
- break 1
+ if [[ "${ORIG_MESSAGE[$element]}" == "\n" ]]; then
+ first_blank_line=$element
+ # store all lines up to this one in array ORIG_MESSAGE_HEADERS
+ for element in $(seq 0 $(($first_blank_line - 1))); do
+ ORIG_MESSAGE_HEADERS[$element]="${ORIG_MESSAGE[$element]}"
+ done
+ # done, exit for loop
+ break 1
+ fi
done
# list ORIG_MESSAGE_HEADERS and get some specific headers for later use
FROM=$(echo -e "${ORIG_MESSAGE_HEADERS[@]}" | grep -m 1 '^ From:' | cut -d : -f 2- | sed -e 's/^ //')
SENDER_ADDRESS=$(if [[ -z "$(echo $FROM | grep '>$')" ]]; then echo $FROM; else echo $FROM | grep -o '<[^<>]*>$' | sed -e 's/[<>]//g'; fi)
- DATE=$(echo -e "${ORIG_MESSAGE_HEADERS[@]}" | grep -m 1 '^ Date:' | sed -e 's/^ //')
+ DATE=$(echo -e "${ORIG_MESSAGE_HEADERS[@]}" | grep -m 1 '^ Date:' | cut -d : -f 2- | sed -e 's/^ //')
SUBJECT=$(echo -e "${ORIG_MESSAGE_HEADERS[@]}" | grep -m 1 '^ Subject:' | cut -d : -f 2- | sed -e 's/^ //')
# check if message headers were successfully stored in ORIG_MESSAGE_HEADERS
if [[ "${#ORIG_MESSAGE_HEADERS[@]}" -eq "0" ]]; then
echo "$(basename $0): Message headers could not be located within this message."
- return 1
+ exit 1
fi
}
@@ -320,7 +323,7 @@ function SendListMessage {
MESSAGE_BODY=( $(echo "$PASSPHRASE
Message from: $FROM
Subject: $SUBJECT
-$DATE
+Date: $DATE
$(GetGpgDecryptStderr | grep '^gpg: Signature made')
$(GetGpgDecryptStderr | grep '^gpg: Good signature from')
@@ -346,7 +349,7 @@ function SendWarningMessage {
MESSAGE_BODY=( $(echo "$PASSPHRASE
Message from: $FROM
Subject: [BAD SIGNATURE] $SUBJECT
-$DATE
+Date: $DATE
$(GetGpgDecryptStderr | grep '^gpg: Signature made')
$(GetGpgDecryptStderr | grep '^gpg: BAD signature from')
@@ -374,7 +377,7 @@ Subject: none
Message from: $FROM
Subject: [RETURNED MAIL] $SUBJECT
-$DATE
+Date: $DATE
It was not possible to process this message. Either or both
the message was not encrypted and/or signed, or you are not