Hi, The problem relies in the parser code: it relies on the fact that "char" are unsigned which is untrue on PPC.
Attached is a patch that fixes the following in the parser: * Buffer overflow for any string longer than 500 chars. * Errors appearing on PowerPC. * Some warnings. Please note that the package cointains "parser.c" which can be generated from "parser.y". Removing "parser.c" would add a Build-Depends on bison, though. Cheers, J�r�my.
--- ../labplot-1.4.0/src/parser.y 2004-02-02 01:07:34.000000000 +0100
+++ src/parser.y 2005-02-14 13:45:12.000000000 +0100
@@ -49,15 +49,14 @@
symrec *sym_table = (symrec *) 0;
double parse(char *str) {
- int i;
pos=0;
/* reset string, because it's global ! */
- for (i=0;i<500;i++)
- string[i]=EOF;
+ bzero(string, PARSE_STRING_SIZE);
- strcpy(string,str);
- string[strlen(str)]='\n';
+ /* leave space to terminate string by "\n\0" */
+ strncpy(string, str, PARSE_STRING_SIZE - 2);
+ string[strlen(string)] = '\n';
init_table();
yyparse();
@@ -114,9 +113,9 @@
}
static int getcharstr(void) {
- if (pos >= strlen(string))
+ if ('\0' == string[pos])
return EOF;
- return (string[pos++]);
+ return (int) string[pos++];
}
static void ungetcstr(void) {
--- ../labplot-1.4.0/src/parser.h 2004-02-02 01:06:37.000000000 +0100
+++ src/parser.h 2005-02-14 13:32:09.000000000 +0100
@@ -46,18 +46,21 @@
typedef struct symrec symrec;
-symrec *putsym (const char *,int func_t);
+double parse(char *str);
+symrec *putsym (const char *, int);
symrec *getsym (const char *);
void init_table(void);
int yyerror (const char*);
-int yylex ();
+int yylex(void);
+
+#define PARSE_STRING_SIZE 500
double res;
int pos;
-char string[500];
+unsigned char string[PARSE_STRING_SIZE];
struct init {
- char *fname;
+ char const *fname;
#ifdef USE_SOLARIS
double (*fnct)(double);
#else
@@ -66,7 +69,7 @@
};
struct con {
- char *name;
+ char const *name;
double value;
};
pgpCgeSAXl0mB.pgp
Description: PGP signature

