Commit b59e2b58 authored by Bernhard Link's avatar Bernhard Link

Even some more checks

parent b60444f1
/* This file is part of "reprepro"
* Copyright (C) 2003 Bernhard R. Link
* Copyright (C) 2003,2004 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
......@@ -167,6 +167,8 @@ static retvalue dsc_read(struct dscpackage **pkg, const char *filename) {
fprintf(stderr,"Missing 'Source'-header in %s!\n",filename);
r = RET_ERROR;
}
if( RET_IS_OK(r) )
r = properpackagename(dsc->package);
if( RET_WAS_ERROR(r) ) {
dsc_free(dsc);
return r;
......@@ -180,6 +182,9 @@ static retvalue dsc_read(struct dscpackage **pkg, const char *filename) {
(void) checkvalue(filename,dsc->control,"Standards-Version");
r = getvalue(filename,dsc->control,"Version",&dsc->version);
if( RET_IS_OK(r) ) {
r = propername(dsc->version);
}
if( RET_WAS_ERROR(r) ) {
dsc_free(dsc);
return r;
......@@ -196,6 +201,8 @@ static retvalue dsc_read(struct dscpackage **pkg, const char *filename) {
return r;
}
r = sources_parse_getmd5sums(dsc->control,&dsc->basenames,&dsc->md5sums);
if( RET_IS_OK(r) )
r = propernames(&dsc->basenames);
if( RET_WAS_ERROR(r) ) {
dsc_free(dsc);
return r;
......
......@@ -31,8 +31,12 @@ retvalue propername(const char *string) {
const unsigned char *s;
assert( string != NULL );
if( string[0] == '.' && string[1] == '\0' ) {
fprintf(stderr,"Version/Architecture/Files/... must be more than a single dot!\n");
return RET_ERROR;
}
if( string[0] == '.' && string[1] == '.' ) {
fprintf(stderr,"Names may not start with two dots!\n");
fprintf(stderr,"Version/Architecture/Files/... identifiers may not start with two dots!\n");
return RET_ERROR;
}
s = string;
......@@ -48,6 +52,18 @@ retvalue propername(const char *string) {
}
retvalue propernames(const struct strlist *names) {
int i;
for( i = 0 ; i < names->count ; i ++ ) {
retvalue r = propername(names->values[i]);
assert( r != RET_NOTHING );
if( RET_WAS_ERROR(r) )
return r;
}
return RET_OK;
}
retvalue properpackagename(const char *string) {
const unsigned char *s;
assert( string != NULL );
......
......@@ -42,6 +42,7 @@ retvalue names_checkbasename(const char *basename);
/* check for forbidden characters */
retvalue propername(const char *string);
retvalue propernames(const struct strlist *names);
retvalue properpackagename(const char *string);
#endif
......@@ -161,16 +161,11 @@ static inline retvalue calcnewcontrol(
struct strlist *filekeys,char **newchunk,struct strlist *origfiles) {
char *directory;
retvalue r;
int i;
r = properpackagename(package);
assert( r != RET_NOTHING );
i = 0;
while( RET_IS_OK(r) && i < basenames->count ) {
r = propername(basenames->values[i]);
assert( r != RET_NOTHING );
i++;
}
if( RET_IS_OK(r) )
r = propernames(basenames);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr,"Forbidden characters in source package '%s'!\n",package);
return r;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment