|
From: <ssm...@us...> - 2007-11-15 16:05:07
|
Revision: 2682
http://selinux.svn.sourceforge.net/selinux/?rev=2682&view=rev
Author: ssmalley
Date: 2007-11-15 06:52:12 -0800 (Thu, 15 Nov 2007)
Log Message:
-----------
Initially set the source file name from the argument so that we don't get unknown source in the common case.
Modified Paths:
--------------
trunk/checkpolicy/parse_util.c
trunk/checkpolicy/policy_scan.l
Modified: trunk/checkpolicy/parse_util.c
===================================================================
--- trunk/checkpolicy/parse_util.c 2007-11-09 00:45:40 UTC (rev 2681)
+++ trunk/checkpolicy/parse_util.c 2007-11-15 14:52:12 UTC (rev 2682)
@@ -29,9 +29,9 @@
extern queue_t id_queue;
extern unsigned int policydb_errors;
extern unsigned long policydb_lineno;
-extern char source_file[];
extern policydb_t *policydbp;
extern int mlspol;
+extern void set_source_file(const char *name);
int read_source_policy(policydb_t * p, const char *file, const char *progname)
{
@@ -40,6 +40,7 @@
fprintf(stderr, "%s: unable to open %s\n", progname, file);
return -1;
}
+ set_source_file(file);
if ((id_queue = queue_create()) == NULL) {
fprintf(stderr, "%s: out of memory!\n", progname);
@@ -58,7 +59,7 @@
}
rewind(yyin);
init_parser(2);
- source_file[0] = '\0';
+ set_source_file(file);
yyrestart(yyin);
if (yyparse() || policydb_errors) {
fprintf(stderr,
Modified: trunk/checkpolicy/policy_scan.l
===================================================================
--- trunk/checkpolicy/policy_scan.l 2007-11-09 00:45:40 UTC (rev 2681)
+++ trunk/checkpolicy/policy_scan.l 2007-11-15 14:52:12 UTC (rev 2682)
@@ -21,6 +21,7 @@
%{
#include <sys/types.h>
+#include <limits.h>
#include <stdint.h>
#include <string.h>
@@ -32,7 +33,9 @@
static unsigned int lno = 0;
int yywarn(char *msg);
-char source_file[255];
+void set_source_file(const char *name);
+
+char source_file[PATH_MAX];
unsigned long source_lineno = 1;
unsigned long policydb_lineno = 1;
@@ -204,7 +207,7 @@
{digit}{1,3}(\.{digit}{1,3}){3} { return(IPV4_ADDR); }
{hexval}{0,4}":"{hexval}{0,4}":"({hexval}|[:.])* { return(IPV6_ADDR); }
{digit}+(\.({alnum}|[_.])*)? { return(VERSION_IDENTIFIER); }
-#line[ ]1[ ]\"[^\n]*\" { source_lineno = 1; strncpy(source_file, yytext+9, 255); source_file[strlen(source_file)-1] = '\0'; }
+#line[ ]1[ ]\"[^\n]*\" { set_source_file(yytext+9); }
#line[ ]{digit}+ { source_lineno = atoi(yytext+6)-1; }
#[^\n]* { /* delete comments */ }
[ \t\f]+ { /* delete whitespace */ }
@@ -259,3 +262,10 @@
linebuf[0], linebuf[1]);
return 0;
}
+
+void set_source_file(const char *name)
+{
+ source_lineno = 1;
+ strncpy(source_file, name, sizeof(source_file)-1);
+ source_file[sizeof(source_file)-1] = '\0';
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|