idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
1,200
|
seticc_cal(i_ctx_t * i_ctx_p, float *white, float *black, float *gamma,
float *matrix, int num_colorants, ulong dictkey)
{
int code;
gs_color_space * pcs;
gs_memory_t *mem = igs->memory;
int i;
cmm_profile_t *cal_profile;
/* See if the color space is in the profile cache */
pcs = gsicc_find_cs(dictkey, igs);
if (pcs == NULL ) {
/* build the color space object. Since this is cached
in the profile cache which is a member variable
of the graphic state, we will want to use stable
memory here */
code = gs_cspace_build_ICC(&pcs, NULL, mem->stable_memory);
if (code < 0)
return gs_rethrow(code, "building color space object");
/* There is no alternate for this. Perhaps we should set DeviceRGB? */
pcs->base_space = NULL;
/* Create the ICC profile from the CalRGB or CalGray parameters */
cal_profile = gsicc_create_from_cal(white, black, gamma, matrix,
mem->stable_memory, num_colorants);
if (cal_profile == NULL)
return gs_rethrow(gs_error_VMerror, "creating the cal profile failed");
/* Assign the profile to this color space */
code = gsicc_set_gscs_profile(pcs, cal_profile, mem->stable_memory);
/* profile is created with ref count of 1, gsicc_set_gscs_profile()
* increments the ref count, so we need to decrement it here.
*/
rc_decrement(cal_profile, "seticc_cal");
if (code < 0)
return gs_rethrow(code, "installing the cal profile");
for (i = 0; i < num_colorants; i++) {
pcs->cmm_icc_profile_data->Range.ranges[i].rmin = 0;
pcs->cmm_icc_profile_data->Range.ranges[i].rmax = 1;
}
/* Add the color space to the profile cache */
gsicc_add_cs(igs, pcs,dictkey);
}
/* Set the color space. We are done. */
code = gs_setcolorspace(igs, pcs);
return code;
}
|
Bypass
| 0
|
seticc_cal(i_ctx_t * i_ctx_p, float *white, float *black, float *gamma,
float *matrix, int num_colorants, ulong dictkey)
{
int code;
gs_color_space * pcs;
gs_memory_t *mem = igs->memory;
int i;
cmm_profile_t *cal_profile;
/* See if the color space is in the profile cache */
pcs = gsicc_find_cs(dictkey, igs);
if (pcs == NULL ) {
/* build the color space object. Since this is cached
in the profile cache which is a member variable
of the graphic state, we will want to use stable
memory here */
code = gs_cspace_build_ICC(&pcs, NULL, mem->stable_memory);
if (code < 0)
return gs_rethrow(code, "building color space object");
/* There is no alternate for this. Perhaps we should set DeviceRGB? */
pcs->base_space = NULL;
/* Create the ICC profile from the CalRGB or CalGray parameters */
cal_profile = gsicc_create_from_cal(white, black, gamma, matrix,
mem->stable_memory, num_colorants);
if (cal_profile == NULL)
return gs_rethrow(gs_error_VMerror, "creating the cal profile failed");
/* Assign the profile to this color space */
code = gsicc_set_gscs_profile(pcs, cal_profile, mem->stable_memory);
/* profile is created with ref count of 1, gsicc_set_gscs_profile()
* increments the ref count, so we need to decrement it here.
*/
rc_decrement(cal_profile, "seticc_cal");
if (code < 0)
return gs_rethrow(code, "installing the cal profile");
for (i = 0; i < num_colorants; i++) {
pcs->cmm_icc_profile_data->Range.ranges[i].rmin = 0;
pcs->cmm_icc_profile_data->Range.ranges[i].rmax = 1;
}
/* Add the color space to the profile cache */
gsicc_add_cs(igs, pcs,dictkey);
}
/* Set the color space. We are done. */
code = gs_setcolorspace(igs, pcs);
return code;
}
|
@@ -76,7 +76,7 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff)
want to have this buffer. */
/* Check if we have the /Name entry. This is used to associate with
specs that have enumerated types to indicate sRGB sGray etc */
- if (dict_find_string(ICCdict, "Name", &pnameval) > 0){
+ if (dict_find_string(ICCdict, "Name", &pnameval) > 0 && r_has_type(pnameval, t_string)){
uint size = r_size(pnameval);
char *str = (char *)gs_alloc_bytes(gs_gstate_memory(igs), size+1, "seticc");
memcpy(str, (const char *)pnameval->value.bytes, size);
@@ -263,6 +263,8 @@ zset_outputintent(i_ctx_t * i_ctx_p)
return code;
if (code == 0)
return_error(gs_error_undefined);
+ if (r_type(pnval) != t_integer)
+ return gs_note_error(gs_error_typecheck);
ncomps = pnval->value.intval;
/* verify the DataSource entry. Creat profile from stream */
@@ -495,6 +497,8 @@ znumicc_components(i_ctx_t * i_ctx_p)
return code;
if (code == 0)
return_error(gs_error_undefined);
+ if (r_type(pnval) != t_integer)
+ return gs_note_error(gs_error_typecheck);
ncomps = pnval->value.intval;
/* verify the DataSource entry. Create profile from stream */
if (dict_find_string(op, "DataSource", &pstrmval) <= 0)
|
CWE-704
| null | null |
1,201
|
seticc_lab(i_ctx_t * i_ctx_p, float *white, float *black, float *range_buff)
{
int code;
gs_color_space * pcs;
int i;
/* build the color space object */
code = gs_cspace_build_ICC(&pcs, NULL, gs_gstate_memory(igs));
if (code < 0)
return gs_rethrow(code, "building color space object");
/* record the current space as the alternative color space */
/* Get the lab profile. It may already be set in the icc manager.
If not then lets populate it. */
if (igs->icc_manager->lab_profile == NULL ) {
/* This can't happen as the profile
should be initialized during the
setting of the user params */
return gs_rethrow(code, "cannot find lab icc profile");
}
/* Assign the LAB to LAB profile to this color space */
code = gsicc_set_gscs_profile(pcs, igs->icc_manager->lab_profile, gs_gstate_memory(igs));
if (code < 0)
return gs_rethrow(code, "installing the lab profile");
pcs->cmm_icc_profile_data->Range.ranges[0].rmin = 0.0;
pcs->cmm_icc_profile_data->Range.ranges[0].rmax = 100.0;
for (i = 1; i < 3; i++) {
pcs->cmm_icc_profile_data->Range.ranges[i].rmin =
range_buff[2 * (i-1)];
pcs->cmm_icc_profile_data->Range.ranges[i].rmax =
range_buff[2 * (i-1) + 1];
}
/* Set the color space. We are done. */
code = gs_setcolorspace(igs, pcs);
return code;
}
|
Bypass
| 0
|
seticc_lab(i_ctx_t * i_ctx_p, float *white, float *black, float *range_buff)
{
int code;
gs_color_space * pcs;
int i;
/* build the color space object */
code = gs_cspace_build_ICC(&pcs, NULL, gs_gstate_memory(igs));
if (code < 0)
return gs_rethrow(code, "building color space object");
/* record the current space as the alternative color space */
/* Get the lab profile. It may already be set in the icc manager.
If not then lets populate it. */
if (igs->icc_manager->lab_profile == NULL ) {
/* This can't happen as the profile
should be initialized during the
setting of the user params */
return gs_rethrow(code, "cannot find lab icc profile");
}
/* Assign the LAB to LAB profile to this color space */
code = gsicc_set_gscs_profile(pcs, igs->icc_manager->lab_profile, gs_gstate_memory(igs));
if (code < 0)
return gs_rethrow(code, "installing the lab profile");
pcs->cmm_icc_profile_data->Range.ranges[0].rmin = 0.0;
pcs->cmm_icc_profile_data->Range.ranges[0].rmax = 100.0;
for (i = 1; i < 3; i++) {
pcs->cmm_icc_profile_data->Range.ranges[i].rmin =
range_buff[2 * (i-1)];
pcs->cmm_icc_profile_data->Range.ranges[i].rmax =
range_buff[2 * (i-1) + 1];
}
/* Set the color space. We are done. */
code = gs_setcolorspace(igs, pcs);
return code;
}
|
@@ -76,7 +76,7 @@ int seticc(i_ctx_t * i_ctx_p, int ncomps, ref *ICCdict, float *range_buff)
want to have this buffer. */
/* Check if we have the /Name entry. This is used to associate with
specs that have enumerated types to indicate sRGB sGray etc */
- if (dict_find_string(ICCdict, "Name", &pnameval) > 0){
+ if (dict_find_string(ICCdict, "Name", &pnameval) > 0 && r_has_type(pnameval, t_string)){
uint size = r_size(pnameval);
char *str = (char *)gs_alloc_bytes(gs_gstate_memory(igs), size+1, "seticc");
memcpy(str, (const char *)pnameval->value.bytes, size);
@@ -263,6 +263,8 @@ zset_outputintent(i_ctx_t * i_ctx_p)
return code;
if (code == 0)
return_error(gs_error_undefined);
+ if (r_type(pnval) != t_integer)
+ return gs_note_error(gs_error_typecheck);
ncomps = pnval->value.intval;
/* verify the DataSource entry. Creat profile from stream */
@@ -495,6 +497,8 @@ znumicc_components(i_ctx_t * i_ctx_p)
return code;
if (code == 0)
return_error(gs_error_undefined);
+ if (r_type(pnval) != t_integer)
+ return gs_note_error(gs_error_typecheck);
ncomps = pnval->value.intval;
/* verify the DataSource entry. Create profile from stream */
if (dict_find_string(op, "DataSource", &pstrmval) <= 0)
|
CWE-704
| null | null |
1,202
|
push_callout(i_ctx_t *i_ctx_p, const char *callout_name)
{
int code;
check_estack(1);
code = name_enter_string(imemory, callout_name, esp + 1);
if (code < 0)
return code;
++esp;
r_set_attrs(esp, a_executable);
return o_push_estack;
}
|
Bypass
| 0
|
push_callout(i_ctx_t *i_ctx_p, const char *callout_name)
{
int code;
check_estack(1);
code = name_enter_string(imemory, callout_name, esp + 1);
if (code < 0)
return code;
++esp;
r_set_attrs(esp, a_executable);
return o_push_estack;
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,203
|
z2copy(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code = zcopy(i_ctx_p);
if (code >= 0)
return code;
if (!r_has_type(op, t_astruct))
return code;
return z2copy_gstate(i_ctx_p);
}
|
Bypass
| 0
|
z2copy(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code = zcopy(i_ctx_p);
if (code >= 0)
return code;
if (!r_has_type(op, t_astruct))
return code;
return z2copy_gstate(i_ctx_p);
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,204
|
z2currentgstate(i_ctx_t *i_ctx_p)
{
if (!save_page_device(igs))
return zcurrentgstate(i_ctx_p);
return push_callout(i_ctx_p, "%currentgstatepagedevice");
}
|
Bypass
| 0
|
z2currentgstate(i_ctx_t *i_ctx_p)
{
if (!save_page_device(igs))
return zcurrentgstate(i_ctx_p);
return push_callout(i_ctx_p, "%currentgstatepagedevice");
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,205
|
z2grestoreall(i_ctx_t *i_ctx_p)
{
for (;;) {
int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code == 0) {
bool done = !gs_gstate_saved(gs_gstate_saved(igs));
gs_grestore(igs);
if (done)
break;
} else
return push_callout(i_ctx_p, "%grestoreallpagedevice");
}
return 0;
}
|
Bypass
| 0
|
z2grestoreall(i_ctx_t *i_ctx_p)
{
for (;;) {
int code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code == 0) {
bool done = !gs_gstate_saved(gs_gstate_saved(igs));
gs_grestore(igs);
if (done)
break;
} else
return push_callout(i_ctx_p, "%grestoreallpagedevice");
}
return 0;
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,206
|
z2gstate(i_ctx_t *i_ctx_p)
{
if (!save_page_device(igs))
return zgstate(i_ctx_p);
return push_callout(i_ctx_p, "%gstatepagedevice");
}
|
Bypass
| 0
|
z2gstate(i_ctx_t *i_ctx_p)
{
if (!save_page_device(igs))
return zgstate(i_ctx_p);
return push_callout(i_ctx_p, "%gstatepagedevice");
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,207
|
z2restore(i_ctx_t *i_ctx_p)
{
alloc_save_t *asave;
bool saveLockSafety = gs_currentdevice_inline(igs)->LockSafetyParams;
int code = restore_check_save(i_ctx_p, &asave);
if (code < 0) return code;
while (gs_gstate_saved(gs_gstate_saved(igs))) {
code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code > 0)
return push_callout(i_ctx_p, "%restore1pagedevice");
gs_grestore(igs);
}
code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code > 0)
return push_callout(i_ctx_p, "%restorepagedevice");
code = dorestore(i_ctx_p, asave);
if (code < 0) {
/* An error here is basically fatal, but....
restore_page_device() has to set LockSafetyParams false so it can
configure the restored device correctly - in normal operation, that
gets reset by that configuration. If we hit an error, though, that
may not happen - at least ensure we keep the setting through the
error.
*/
gs_currentdevice_inline(igs)->LockSafetyParams = saveLockSafety;
}
return code;
}
|
Bypass
| 0
|
z2restore(i_ctx_t *i_ctx_p)
{
alloc_save_t *asave;
bool saveLockSafety = gs_currentdevice_inline(igs)->LockSafetyParams;
int code = restore_check_save(i_ctx_p, &asave);
if (code < 0) return code;
while (gs_gstate_saved(gs_gstate_saved(igs))) {
code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code > 0)
return push_callout(i_ctx_p, "%restore1pagedevice");
gs_grestore(igs);
}
code = restore_page_device(i_ctx_p, igs, gs_gstate_saved(igs));
if (code < 0) return code;
if (code > 0)
return push_callout(i_ctx_p, "%restorepagedevice");
code = dorestore(i_ctx_p, asave);
if (code < 0) {
/* An error here is basically fatal, but....
restore_page_device() has to set LockSafetyParams false so it can
configure the restored device correctly - in normal operation, that
gets reset by that configuration. If we hit an error, though, that
may not happen - at least ensure we keep the setting through the
error.
*/
gs_currentdevice_inline(igs)->LockSafetyParams = saveLockSafety;
}
return code;
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,208
|
z2save(i_ctx_t *i_ctx_p)
{
if (!save_page_device(igs))
return zsave(i_ctx_p);
return push_callout(i_ctx_p, "%savepagedevice");
}
|
Bypass
| 0
|
z2save(i_ctx_t *i_ctx_p)
{
if (!save_page_device(igs))
return zsave(i_ctx_p);
return push_callout(i_ctx_p, "%savepagedevice");
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,209
|
z2setgstate(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code;
check_stype(*op, st_igstate_obj);
code = restore_page_device(i_ctx_p, igs, igstate_ptr(op));
if (code < 0) return code;
if (code == 0)
return zsetgstate(i_ctx_p);
return push_callout(i_ctx_p, "%setgstatepagedevice");
}
|
Bypass
| 0
|
z2setgstate(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code;
check_stype(*op, st_igstate_obj);
code = restore_page_device(i_ctx_p, igs, igstate_ptr(op));
if (code < 0) return code;
if (code == 0)
return zsetgstate(i_ctx_p);
return push_callout(i_ctx_p, "%setgstatepagedevice");
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,210
|
zcallendpage(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
int code;
check_type(op[-1], t_integer);
check_type(*op, t_integer);
if ((dev = (*dev_proc(dev, get_page_device))(dev)) != 0) {
code = (*dev->page_procs.end_page)(dev, (int)op->value.intval, igs);
if (code < 0)
return code;
if (code > 1)
return_error(gs_error_rangecheck);
} else {
code = (op->value.intval == 2 ? 0 : 1);
}
make_bool(op - 1, code);
pop(1);
return 0;
}
|
Bypass
| 0
|
zcallendpage(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
int code;
check_type(op[-1], t_integer);
check_type(*op, t_integer);
if ((dev = (*dev_proc(dev, get_page_device))(dev)) != 0) {
code = (*dev->page_procs.end_page)(dev, (int)op->value.intval, igs);
if (code < 0)
return code;
if (code > 1)
return_error(gs_error_rangecheck);
} else {
code = (op->value.intval == 2 ? 0 : 1);
}
make_bool(op - 1, code);
pop(1);
return 0;
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,211
|
zcurrentshowpagecount(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev1, *dev = gs_currentdevice(igs);
if ((*dev_proc(dev, get_page_device))(dev) == 0) {
push(1);
make_false(op);
} else {
dev1 = (*dev_proc(dev, get_page_device))(dev);
push(2);
make_int(op - 1, dev1->ShowpageCount);
make_true(op);
}
return 0;
}
|
Bypass
| 0
|
zcurrentshowpagecount(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev1, *dev = gs_currentdevice(igs);
if ((*dev_proc(dev, get_page_device))(dev) == 0) {
push(1);
make_false(op);
} else {
dev1 = (*dev_proc(dev, get_page_device))(dev);
push(2);
make_int(op - 1, dev1->ShowpageCount);
make_true(op);
}
return 0;
}
|
@@ -277,7 +277,7 @@ restore_page_device(i_ctx_t *i_ctx_p, const gs_gstate * pgs_old, const gs_gstate
samepagedevice = false;
}
- if (LockSafetyParams && !samepagedevice) {
+ if (LockSafetyParams) {
const int required_ops = 512;
const int required_es = 32;
| null | null | null |
1,212
|
zcopydevice2(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *new_dev;
int code;
check_read_type(op[-1], t_device);
check_type(*op, t_boolean);
if (op[-1].value.pdevice == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
code = gs_copydevice2(&new_dev, op[-1].value.pdevice, op->value.boolval,
imemory);
if (code < 0)
return code;
new_dev->memory = imemory;
make_tav(op - 1, t_device, icurrent_space | a_all, pdevice, new_dev);
pop(1);
return 0;
}
| null | 0
|
zcopydevice2(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *new_dev;
int code;
check_read_type(op[-1], t_device);
check_type(*op, t_boolean);
if (op[-1].value.pdevice == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
code = gs_copydevice2(&new_dev, op[-1].value.pdevice, op->value.boolval,
imemory);
if (code < 0)
return code;
new_dev->memory = imemory;
make_tav(op - 1, t_device, icurrent_space | a_all, pdevice, new_dev);
pop(1);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,213
|
zcurrentdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
gs_ref_memory_t *mem = (gs_ref_memory_t *) dev->memory;
push(1);
make_tav(op, t_device,
(mem == 0 ? avm_foreign : imemory_space(mem)) | a_all,
pdevice, dev);
return 0;
}
| null | 0
|
zcurrentdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
gs_ref_memory_t *mem = (gs_ref_memory_t *) dev->memory;
push(1);
make_tav(op, t_device,
(mem == 0 ? avm_foreign : imemory_space(mem)) | a_all,
pdevice, dev);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,214
|
zcurrentoutputdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *odev = NULL, *dev = gs_currentdevice(igs);
gs_ref_memory_t *mem = (gs_ref_memory_t *) dev->memory;
int code = dev_proc(dev, dev_spec_op)(dev,
gxdso_current_output_device, (void *)&odev, 0);
if (code < 0)
return code;
push(1);
make_tav(op, t_device,
(mem == 0 ? avm_foreign : imemory_space(mem)) | a_all,
pdevice, odev);
return 0;
}
| null | 0
|
zcurrentoutputdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *odev = NULL, *dev = gs_currentdevice(igs);
gs_ref_memory_t *mem = (gs_ref_memory_t *) dev->memory;
int code = dev_proc(dev, dev_spec_op)(dev,
gxdso_current_output_device, (void *)&odev, 0);
if (code < 0)
return code;
push(1);
make_tav(op, t_device,
(mem == 0 ? avm_foreign : imemory_space(mem)) | a_all,
pdevice, odev);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,215
|
zdevicename(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const char *dname;
check_read_type(*op, t_device);
if (op->value.pdevice == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
dname = op->value.pdevice->dname;
make_const_string(op, avm_foreign | a_readonly, strlen(dname),
(const byte *)dname);
return 0;
}
| null | 0
|
zdevicename(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const char *dname;
check_read_type(*op, t_device);
if (op->value.pdevice == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
dname = op->value.pdevice->dname;
make_const_string(op, avm_foreign | a_readonly, strlen(dname),
(const byte *)dname);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,216
|
zdoneshowpage(i_ctx_t *i_ctx_p)
{
gx_device *dev = gs_currentdevice(igs);
gx_device *tdev = (*dev_proc(dev, get_page_device)) (dev);
if (tdev != 0)
tdev->ShowpageCount++;
return 0;
}
| null | 0
|
zdoneshowpage(i_ctx_t *i_ctx_p)
{
gx_device *dev = gs_currentdevice(igs);
gx_device *tdev = (*dev_proc(dev, get_page_device)) (dev);
if (tdev != 0)
tdev->ShowpageCount++;
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,217
|
zget_device_params(i_ctx_t *i_ctx_p, bool is_hardware)
{
os_ptr op = osp;
ref rkeys;
gx_device *dev;
stack_param_list list;
int code;
ref *pmark;
check_read_type(op[-1], t_device);
if(!r_has_type(op, t_null)) {
check_type(*op, t_dictionary);
}
rkeys = *op;
dev = op[-1].value.pdevice;
if (op[-1].value.pdevice == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
pop(1);
stack_param_list_write(&list, &o_stack, &rkeys, iimemory);
code = gs_get_device_or_hardware_params(dev, (gs_param_list *) & list,
is_hardware);
if (code < 0) {
/* We have to put back the top argument. */
if (list.count > 0)
ref_stack_pop(&o_stack, list.count * 2 - 1);
else
ref_stack_push(&o_stack, 1);
*osp = rkeys;
return code;
}
pmark = ref_stack_index(&o_stack, list.count * 2);
make_mark(pmark);
return 0;
}
| null | 0
|
zget_device_params(i_ctx_t *i_ctx_p, bool is_hardware)
{
os_ptr op = osp;
ref rkeys;
gx_device *dev;
stack_param_list list;
int code;
ref *pmark;
check_read_type(op[-1], t_device);
if(!r_has_type(op, t_null)) {
check_type(*op, t_dictionary);
}
rkeys = *op;
dev = op[-1].value.pdevice;
if (op[-1].value.pdevice == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
pop(1);
stack_param_list_write(&list, &o_stack, &rkeys, iimemory);
code = gs_get_device_or_hardware_params(dev, (gs_param_list *) & list,
is_hardware);
if (code < 0) {
/* We have to put back the top argument. */
if (list.count > 0)
ref_stack_pop(&o_stack, list.count * 2 - 1);
else
ref_stack_push(&o_stack, 1);
*osp = rkeys;
return code;
}
pmark = ref_stack_index(&o_stack, list.count * 2);
make_mark(pmark);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,218
|
zgetbitsrect(i_ctx_t *i_ctx_p)
{ /*
* alpha? is 0 for no alpha, -1 for alpha first, 1 for alpha last.
* std_depth is null for native pixels, depth/component for
* standard color space.
*/
os_ptr op = osp;
gx_device *dev;
gs_int_rect rect;
gs_get_bits_params_t params;
int w, h;
gs_get_bits_options_t options =
GB_ALIGN_ANY | GB_RETURN_COPY | GB_OFFSET_0 | GB_RASTER_STANDARD |
GB_PACKING_CHUNKY;
int depth;
uint raster;
int num_rows;
int code;
check_read_type(op[-7], t_device);
dev = op[-7].value.pdevice;
if (dev == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
check_int_leu(op[-6], dev->width);
rect.p.x = op[-6].value.intval;
check_int_leu(op[-5], dev->height);
rect.p.y = op[-5].value.intval;
check_int_leu(op[-4], dev->width);
w = op[-4].value.intval;
check_int_leu(op[-3], dev->height);
h = op[-3].value.intval;
check_type(op[-2], t_integer);
/*
* We use if/else rather than switch because the value is long,
* which is not supported as a switch value in pre-ANSI C.
*/
if (op[-2].value.intval == -1)
options |= GB_ALPHA_FIRST;
else if (op[-2].value.intval == 0)
options |= GB_ALPHA_NONE;
else if (op[-2].value.intval == 1)
options |= GB_ALPHA_LAST;
else
return_error(gs_error_rangecheck);
if (r_has_type(op - 1, t_null)) {
options |= GB_COLORS_NATIVE;
depth = dev->color_info.depth;
} else {
static const gs_get_bits_options_t depths[17] = {
0, GB_DEPTH_1, GB_DEPTH_2, 0, GB_DEPTH_4, 0, 0, 0, GB_DEPTH_8,
0, 0, 0, GB_DEPTH_12, 0, 0, 0, GB_DEPTH_16
};
gs_get_bits_options_t depth_option;
int std_depth;
check_int_leu(op[-1], 16);
std_depth = (int)op[-1].value.intval;
depth_option = depths[std_depth];
if (depth_option == 0)
return_error(gs_error_rangecheck);
options |= depth_option | GB_COLORS_NATIVE;
depth = (dev->color_info.num_components +
(options & GB_ALPHA_NONE ? 0 : 1)) * std_depth;
}
if (w == 0)
return_error(gs_error_rangecheck);
raster = (w * depth + 7) >> 3;
check_write_type(*op, t_string);
num_rows = r_size(op) / raster;
h = min(h, num_rows);
if (h == 0)
return_error(gs_error_rangecheck);
rect.q.x = rect.p.x + w;
rect.q.y = rect.p.y + h;
params.options = options;
params.data[0] = op->value.bytes;
code = (*dev_proc(dev, get_bits_rectangle))(dev, &rect, ¶ms, NULL);
if (code < 0)
return code;
make_int(op - 7, h);
op[-6] = *op;
r_set_size(op - 6, h * raster);
pop(6);
return 0;
}
| null | 0
|
zgetbitsrect(i_ctx_t *i_ctx_p)
{ /*
* alpha? is 0 for no alpha, -1 for alpha first, 1 for alpha last.
* std_depth is null for native pixels, depth/component for
* standard color space.
*/
os_ptr op = osp;
gx_device *dev;
gs_int_rect rect;
gs_get_bits_params_t params;
int w, h;
gs_get_bits_options_t options =
GB_ALIGN_ANY | GB_RETURN_COPY | GB_OFFSET_0 | GB_RASTER_STANDARD |
GB_PACKING_CHUNKY;
int depth;
uint raster;
int num_rows;
int code;
check_read_type(op[-7], t_device);
dev = op[-7].value.pdevice;
if (dev == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
check_int_leu(op[-6], dev->width);
rect.p.x = op[-6].value.intval;
check_int_leu(op[-5], dev->height);
rect.p.y = op[-5].value.intval;
check_int_leu(op[-4], dev->width);
w = op[-4].value.intval;
check_int_leu(op[-3], dev->height);
h = op[-3].value.intval;
check_type(op[-2], t_integer);
/*
* We use if/else rather than switch because the value is long,
* which is not supported as a switch value in pre-ANSI C.
*/
if (op[-2].value.intval == -1)
options |= GB_ALPHA_FIRST;
else if (op[-2].value.intval == 0)
options |= GB_ALPHA_NONE;
else if (op[-2].value.intval == 1)
options |= GB_ALPHA_LAST;
else
return_error(gs_error_rangecheck);
if (r_has_type(op - 1, t_null)) {
options |= GB_COLORS_NATIVE;
depth = dev->color_info.depth;
} else {
static const gs_get_bits_options_t depths[17] = {
0, GB_DEPTH_1, GB_DEPTH_2, 0, GB_DEPTH_4, 0, 0, 0, GB_DEPTH_8,
0, 0, 0, GB_DEPTH_12, 0, 0, 0, GB_DEPTH_16
};
gs_get_bits_options_t depth_option;
int std_depth;
check_int_leu(op[-1], 16);
std_depth = (int)op[-1].value.intval;
depth_option = depths[std_depth];
if (depth_option == 0)
return_error(gs_error_rangecheck);
options |= depth_option | GB_COLORS_NATIVE;
depth = (dev->color_info.num_components +
(options & GB_ALPHA_NONE ? 0 : 1)) * std_depth;
}
if (w == 0)
return_error(gs_error_rangecheck);
raster = (w * depth + 7) >> 3;
check_write_type(*op, t_string);
num_rows = r_size(op) / raster;
h = min(h, num_rows);
if (h == 0)
return_error(gs_error_rangecheck);
rect.q.x = rect.p.x + w;
rect.q.y = rect.p.y + h;
params.options = options;
params.data[0] = op->value.bytes;
code = (*dev_proc(dev, get_bits_rectangle))(dev, &rect, ¶ms, NULL);
if (code < 0)
return code;
make_int(op - 7, h);
op[-6] = *op;
r_set_size(op - 6, h * raster);
pop(6);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,219
|
zgetdefaultdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const gx_device *dev;
dev = gs_getdefaultlibdevice(imemory);
if (dev == 0) /* couldn't find a default device */
return_error(gs_error_unknownerror);
push(1);
make_tav(op, t_device, avm_foreign | a_readonly, pdevice,
(gx_device *) dev);
return 0;
}
| null | 0
|
zgetdefaultdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const gx_device *dev;
dev = gs_getdefaultlibdevice(imemory);
if (dev == 0) /* couldn't find a default device */
return_error(gs_error_unknownerror);
push(1);
make_tav(op, t_device, avm_foreign | a_readonly, pdevice,
(gx_device *) dev);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,220
|
zgetdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const gx_device *dev;
check_type(*op, t_integer);
if (op->value.intval != (int)(op->value.intval))
return_error(gs_error_rangecheck); /* won't fit in an int */
dev = gs_getdevice((int)(op->value.intval));
if (dev == 0) /* index out of range */
return_error(gs_error_rangecheck);
/* Device prototypes are read-only; */
/* the cast is logically unnecessary. */
make_tav(op, t_device, avm_foreign | a_readonly, pdevice,
(gx_device *) dev);
return 0;
}
| null | 0
|
zgetdevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
const gx_device *dev;
check_type(*op, t_integer);
if (op->value.intval != (int)(op->value.intval))
return_error(gs_error_rangecheck); /* won't fit in an int */
dev = gs_getdevice((int)(op->value.intval));
if (dev == 0) /* index out of range */
return_error(gs_error_rangecheck);
/* Device prototypes are read-only; */
/* the cast is logically unnecessary. */
make_tav(op, t_device, avm_foreign | a_readonly, pdevice,
(gx_device *) dev);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,221
|
zgetdeviceparams(i_ctx_t *i_ctx_p)
{
return zget_device_params(i_ctx_p, false);
}
| null | 0
|
zgetdeviceparams(i_ctx_t *i_ctx_p)
{
return zget_device_params(i_ctx_p, false);
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,222
|
zmakewordimagedevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
os_ptr op1 = op - 1;
gs_matrix imat;
gx_device *new_dev;
const byte *colors;
int colors_size;
int code;
check_int_leu(op[-3], max_uint >> 1); /* width */
check_int_leu(op[-2], max_uint >> 1); /* height */
check_type(*op, t_boolean);
if (r_has_type(op1, t_null)) { /* true color */
colors = 0;
colors_size = -24; /* 24-bit true color */
} else if (r_has_type(op1, t_integer)) {
/*
* We use if/else rather than switch because the value is long,
* which is not supported as a switch value in pre-ANSI C.
*/
if (op1->value.intval != 16 && op1->value.intval != 24 &&
op1->value.intval != 32
)
return_error(gs_error_rangecheck);
colors = 0;
colors_size = -op1->value.intval;
} else {
check_type(*op1, t_string); /* palette */
if (r_size(op1) > 3 * 256)
return_error(gs_error_rangecheck);
colors = op1->value.bytes;
colors_size = r_size(op1);
}
if ((code = read_matrix(imemory, op - 4, &imat)) < 0)
return code;
/* Everything OK, create device */
code = gs_makewordimagedevice(&new_dev, &imat,
(int)op[-3].value.intval,
(int)op[-2].value.intval,
colors, colors_size,
op->value.boolval, true, imemory);
if (code == 0) {
new_dev->memory = imemory;
make_tav(op - 4, t_device, imemory_space(iimemory) | a_all,
pdevice, new_dev);
pop(4);
}
return code;
}
| null | 0
|
zmakewordimagedevice(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
os_ptr op1 = op - 1;
gs_matrix imat;
gx_device *new_dev;
const byte *colors;
int colors_size;
int code;
check_int_leu(op[-3], max_uint >> 1); /* width */
check_int_leu(op[-2], max_uint >> 1); /* height */
check_type(*op, t_boolean);
if (r_has_type(op1, t_null)) { /* true color */
colors = 0;
colors_size = -24; /* 24-bit true color */
} else if (r_has_type(op1, t_integer)) {
/*
* We use if/else rather than switch because the value is long,
* which is not supported as a switch value in pre-ANSI C.
*/
if (op1->value.intval != 16 && op1->value.intval != 24 &&
op1->value.intval != 32
)
return_error(gs_error_rangecheck);
colors = 0;
colors_size = -op1->value.intval;
} else {
check_type(*op1, t_string); /* palette */
if (r_size(op1) > 3 * 256)
return_error(gs_error_rangecheck);
colors = op1->value.bytes;
colors_size = r_size(op1);
}
if ((code = read_matrix(imemory, op - 4, &imat)) < 0)
return code;
/* Everything OK, create device */
code = gs_makewordimagedevice(&new_dev, &imat,
(int)op[-3].value.intval,
(int)op[-2].value.intval,
colors, colors_size,
op->value.boolval, true, imemory);
if (code == 0) {
new_dev->memory = imemory;
make_tav(op - 4, t_device, imemory_space(iimemory) | a_all,
pdevice, new_dev);
pop(4);
}
return code;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,223
|
znulldevice(i_ctx_t *i_ctx_p)
{
int code = gs_nulldevice(igs);
invalidate_stack_devices(i_ctx_p);
clear_pagedevice(istate);
return code;
}
| null | 0
|
znulldevice(i_ctx_t *i_ctx_p)
{
int code = gs_nulldevice(igs);
invalidate_stack_devices(i_ctx_p);
clear_pagedevice(istate);
return code;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,224
|
zoutputpage(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code;
check_type(op[-1], t_integer);
check_type(*op, t_boolean);
if (gs_debug[':']) {
gs_main_instance *minst = get_minst_from_memory((gs_memory_t *)i_ctx_p->memory.current->non_gc_memory);
print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage start");
}
code = gs_output_page(igs, (int)op[-1].value.intval,
op->value.boolval);
if (code < 0)
return code;
pop(2);
if (gs_debug[':']) {
gs_main_instance *minst = get_minst_from_memory((gs_memory_t *)i_ctx_p->memory.current->non_gc_memory);
print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage end");
}
return 0;
}
| null | 0
|
zoutputpage(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
int code;
check_type(op[-1], t_integer);
check_type(*op, t_boolean);
if (gs_debug[':']) {
gs_main_instance *minst = get_minst_from_memory((gs_memory_t *)i_ctx_p->memory.current->non_gc_memory);
print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage start");
}
code = gs_output_page(igs, (int)op[-1].value.intval,
op->value.boolval);
if (code < 0)
return code;
pop(2);
if (gs_debug[':']) {
gs_main_instance *minst = get_minst_from_memory((gs_memory_t *)i_ctx_p->memory.current->non_gc_memory);
print_resource_usage(minst, &(i_ctx_p->memory), "Outputpage end");
}
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,225
|
zputdeviceparams(i_ctx_t *i_ctx_p)
{
uint count = ref_stack_counttomark(&o_stack);
ref *prequire_all;
ref *ppolicy;
ref *pdev;
gx_device *dev;
stack_param_list list;
int code;
int old_width, old_height;
int i, dest;
if (count == 0)
return_error(gs_error_unmatchedmark);
prequire_all = ref_stack_index(&o_stack, count);
ppolicy = ref_stack_index(&o_stack, count + 1);
pdev = ref_stack_index(&o_stack, count + 2);
if (pdev == 0)
return_error(gs_error_stackunderflow);
check_type_only(*prequire_all, t_boolean);
check_write_type_only(*pdev, t_device);
dev = pdev->value.pdevice;
if (dev == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
code = stack_param_list_read(&list, &o_stack, 0, ppolicy,
prequire_all->value.boolval, iimemory);
if (code < 0)
return code;
old_width = dev->width;
old_height = dev->height;
code = gs_putdeviceparams(dev, (gs_param_list *) & list);
/* Check for names that were undefined or caused errors. */
for (dest = count - 2, i = 0; i < count >> 1; i++)
if (list.results[i] < 0) {
*ref_stack_index(&o_stack, dest) =
*ref_stack_index(&o_stack, count - (i << 1) - 2);
gs_errorname(i_ctx_p, list.results[i],
ref_stack_index(&o_stack, dest - 1));
dest -= 2;
}
iparam_list_release(&list);
if (code < 0) { /* There were errors reported. */
ref_stack_pop(&o_stack, dest + 1);
return (code == gs_error_Fatal) ? code : 0; /* cannot continue from Fatal */
}
if (code > 0 || (code == 0 && (dev->width != old_width || dev->height != old_height))) {
/*
* The device was open and is now closed, or its dimensions have
* changed. If it was the current device, call setdevice to
* reinstall it and erase the page.
*/
/****** DOESN'T FIND ALL THE GSTATES THAT REFERENCE THE DEVICE. ******/
if (gs_currentdevice(igs) == dev) {
bool was_open = dev->is_open;
code = gs_setdevice_no_erase(igs, dev);
/* If the device wasn't closed, setdevice won't erase the page. */
if (was_open && code >= 0)
code = 1;
}
}
if (code < 0)
return code;
ref_stack_pop(&o_stack, count + 1);
make_bool(osp, code);
clear_pagedevice(istate);
return 0;
}
| null | 0
|
zputdeviceparams(i_ctx_t *i_ctx_p)
{
uint count = ref_stack_counttomark(&o_stack);
ref *prequire_all;
ref *ppolicy;
ref *pdev;
gx_device *dev;
stack_param_list list;
int code;
int old_width, old_height;
int i, dest;
if (count == 0)
return_error(gs_error_unmatchedmark);
prequire_all = ref_stack_index(&o_stack, count);
ppolicy = ref_stack_index(&o_stack, count + 1);
pdev = ref_stack_index(&o_stack, count + 2);
if (pdev == 0)
return_error(gs_error_stackunderflow);
check_type_only(*prequire_all, t_boolean);
check_write_type_only(*pdev, t_device);
dev = pdev->value.pdevice;
if (dev == NULL)
/* This can happen if we invalidated devices on the stack by calling nulldevice after they were pushed */
return_error(gs_error_undefined);
code = stack_param_list_read(&list, &o_stack, 0, ppolicy,
prequire_all->value.boolval, iimemory);
if (code < 0)
return code;
old_width = dev->width;
old_height = dev->height;
code = gs_putdeviceparams(dev, (gs_param_list *) & list);
/* Check for names that were undefined or caused errors. */
for (dest = count - 2, i = 0; i < count >> 1; i++)
if (list.results[i] < 0) {
*ref_stack_index(&o_stack, dest) =
*ref_stack_index(&o_stack, count - (i << 1) - 2);
gs_errorname(i_ctx_p, list.results[i],
ref_stack_index(&o_stack, dest - 1));
dest -= 2;
}
iparam_list_release(&list);
if (code < 0) { /* There were errors reported. */
ref_stack_pop(&o_stack, dest + 1);
return (code == gs_error_Fatal) ? code : 0; /* cannot continue from Fatal */
}
if (code > 0 || (code == 0 && (dev->width != old_width || dev->height != old_height))) {
/*
* The device was open and is now closed, or its dimensions have
* changed. If it was the current device, call setdevice to
* reinstall it and erase the page.
*/
/****** DOESN'T FIND ALL THE GSTATES THAT REFERENCE THE DEVICE. ******/
if (gs_currentdevice(igs) == dev) {
bool was_open = dev->is_open;
code = gs_setdevice_no_erase(igs, dev);
/* If the device wasn't closed, setdevice won't erase the page. */
if (was_open && code >= 0)
code = 1;
}
}
if (code < 0)
return code;
ref_stack_pop(&o_stack, count + 1);
make_bool(osp, code);
clear_pagedevice(istate);
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,226
|
zspec_op(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
int i, nprocs = sizeof(spec_op_defs) / sizeof(spec_op_t), code, proc = -1;
ref opname, nref, namestr;
char *data;
/* At the very minimum we need a name object telling us which sepc_op to perform */
check_op(1);
if (!r_has_type(op, t_name))
return_error(gs_error_typecheck);
ref_assign(&opname, op);
/* Find the relevant spec_op name */
for (i=0;i<nprocs;i++) {
code = names_ref(imemory->gs_lib_ctx->gs_name_table, (const byte *)spec_op_defs[i].name, strlen(spec_op_defs[i].name), &nref, 0);
if (code < 0)
return code;
if (name_eq(&opname, &nref)) {
proc = i;
break;
}
}
if (proc < 0)
return_error(gs_error_undefined);
pop(1); /* We don't need the name of the spec_op any more */
op = osp;
switch(proc) {
case 0:
{
stack_param_list list;
dev_param_req_t request;
ref rkeys;
/* Get a single device parameter, we should be supplied with
* the name of the paramter, as a name object.
*/
check_op(1);
if (!r_has_type(op, t_name))
return_error(gs_error_typecheck);
ref_assign(&opname, op);
name_string_ref(imemory, &opname, &namestr);
data = (char *)gs_alloc_bytes(imemory, r_size(&namestr) + 1, "temporary special_op string");
if (data == 0)
return_error(gs_error_VMerror);
memset(data, 0x00, r_size(&namestr) + 1);
memcpy(data, namestr.value.bytes, r_size(&namestr));
/* Discard the parameter name now, we're done with it */
pop (1);
/* Make a null object so that the stack param list won't check for requests */
make_null(&rkeys);
stack_param_list_write(&list, &o_stack, &rkeys, iimemory);
/* Stuff the data into a structure for passing to the spec_op */
request.Param = data;
request.list = &list;
code = dev_proc(dev, dev_spec_op)(dev, gxdso_get_dev_param, &request, sizeof(dev_param_req_t));
gs_free_object(imemory, data, "temporary special_op string");
if (code < 0) {
if (code == gs_error_undefined) {
op = osp;
push(1);
make_bool(op, 0);
} else
return_error(code);
} else {
op = osp;
push(1);
make_bool(op, 1);
}
}
break;
default:
/* Belt and braces; it shold not be possible to get here, as the table
* containing the names should mirror the entries in this switch. If we
* found a name there should be a matching case here.
*/
return_error(gs_error_undefined);
break;
}
return 0;
}
| null | 0
|
zspec_op(i_ctx_t *i_ctx_p)
{
os_ptr op = osp;
gx_device *dev = gs_currentdevice(igs);
int i, nprocs = sizeof(spec_op_defs) / sizeof(spec_op_t), code, proc = -1;
ref opname, nref, namestr;
char *data;
/* At the very minimum we need a name object telling us which sepc_op to perform */
check_op(1);
if (!r_has_type(op, t_name))
return_error(gs_error_typecheck);
ref_assign(&opname, op);
/* Find the relevant spec_op name */
for (i=0;i<nprocs;i++) {
code = names_ref(imemory->gs_lib_ctx->gs_name_table, (const byte *)spec_op_defs[i].name, strlen(spec_op_defs[i].name), &nref, 0);
if (code < 0)
return code;
if (name_eq(&opname, &nref)) {
proc = i;
break;
}
}
if (proc < 0)
return_error(gs_error_undefined);
pop(1); /* We don't need the name of the spec_op any more */
op = osp;
switch(proc) {
case 0:
{
stack_param_list list;
dev_param_req_t request;
ref rkeys;
/* Get a single device parameter, we should be supplied with
* the name of the paramter, as a name object.
*/
check_op(1);
if (!r_has_type(op, t_name))
return_error(gs_error_typecheck);
ref_assign(&opname, op);
name_string_ref(imemory, &opname, &namestr);
data = (char *)gs_alloc_bytes(imemory, r_size(&namestr) + 1, "temporary special_op string");
if (data == 0)
return_error(gs_error_VMerror);
memset(data, 0x00, r_size(&namestr) + 1);
memcpy(data, namestr.value.bytes, r_size(&namestr));
/* Discard the parameter name now, we're done with it */
pop (1);
/* Make a null object so that the stack param list won't check for requests */
make_null(&rkeys);
stack_param_list_write(&list, &o_stack, &rkeys, iimemory);
/* Stuff the data into a structure for passing to the spec_op */
request.Param = data;
request.list = &list;
code = dev_proc(dev, dev_spec_op)(dev, gxdso_get_dev_param, &request, sizeof(dev_param_req_t));
gs_free_object(imemory, data, "temporary special_op string");
if (code < 0) {
if (code == gs_error_undefined) {
op = osp;
push(1);
make_bool(op, 0);
} else
return_error(code);
} else {
op = osp;
push(1);
make_bool(op, 1);
}
}
break;
default:
/* Belt and braces; it shold not be possible to get here, as the table
* containing the names should mirror the entries in this switch. If we
* found a name there should be a matching case here.
*/
return_error(gs_error_undefined);
break;
}
return 0;
}
|
@@ -508,13 +508,17 @@ zputdeviceparams(i_ctx_t *i_ctx_p)
int
zsetdevice(i_ctx_t *i_ctx_p)
{
- gx_device *dev = gs_currentdevice(igs);
+ gx_device *odev = NULL, *dev = gs_currentdevice(igs);
os_ptr op = osp;
- int code = 0;
+ int code = dev_proc(dev, dev_spec_op)(dev,
+ gxdso_current_output_device, (void *)&odev, 0);
+
+ if (code < 0)
+ return code;
check_write_type(*op, t_device);
- if (dev->LockSafetyParams) { /* do additional checking if locked */
- if(op->value.pdevice != dev) /* don't allow a different device */
+ if (odev->LockSafetyParams) { /* do additional checking if locked */
+ if(op->value.pdevice != odev) /* don't allow a different device */
return_error(gs_error_invalidaccess);
}
dev->ShowpageCount = 0;
| null | null | null |
1,227
|
aspath_add_asns (struct aspath *aspath, as_t asno, u_char type, unsigned num)
{
struct assegment *assegment = aspath->segments;
unsigned i;
if (assegment && assegment->type == type)
{
/* extend existing segment */
aspath->segments = assegment_prepend_asns (aspath->segments, asno, num);
}
else
{
/* prepend with new segment */
struct assegment *newsegment = assegment_new (type, num);
for (i = 0; i < num; i++)
newsegment->as[i] = asno;
/* insert potentially replacing empty segment */
if (assegment && assegment->length == 0)
{
newsegment->next = assegment->next;
assegment_free (assegment);
}
else
newsegment->next = assegment;
aspath->segments = newsegment;
}
aspath_str_update (aspath);
return aspath;
}
|
DoS
| 0
|
aspath_add_asns (struct aspath *aspath, as_t asno, u_char type, unsigned num)
{
struct assegment *assegment = aspath->segments;
unsigned i;
if (assegment && assegment->type == type)
{
/* extend existing segment */
aspath->segments = assegment_prepend_asns (aspath->segments, asno, num);
}
else
{
/* prepend with new segment */
struct assegment *newsegment = assegment_new (type, num);
for (i = 0; i < num; i++)
newsegment->as[i] = asno;
/* insert potentially replacing empty segment */
if (assegment && assegment->length == 0)
{
newsegment->next = assegment->next;
assegment_free (assegment);
}
else
newsegment->next = assegment;
aspath->segments = newsegment;
}
aspath_str_update (aspath);
return aspath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,228
|
aspath_add_confed_seq (struct aspath *aspath, as_t asno)
{
return aspath_add_asns (aspath, asno, AS_CONFED_SEQUENCE, 1);
}
|
DoS
| 0
|
aspath_add_confed_seq (struct aspath *aspath, as_t asno)
{
return aspath_add_asns (aspath, asno, AS_CONFED_SEQUENCE, 1);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,229
|
aspath_add_seq (struct aspath *aspath, as_t asno)
{
return aspath_add_asns (aspath, asno, AS_SEQUENCE, 1);
}
|
DoS
| 0
|
aspath_add_seq (struct aspath *aspath, as_t asno)
{
return aspath_add_asns (aspath, asno, AS_SEQUENCE, 1);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,230
|
aspath_add_seq_n (struct aspath *aspath, as_t asno, unsigned num)
{
return aspath_add_asns (aspath, asno, AS_SEQUENCE, num);
}
|
DoS
| 0
|
aspath_add_seq_n (struct aspath *aspath, as_t asno, unsigned num)
{
return aspath_add_asns (aspath, asno, AS_SEQUENCE, num);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,231
|
aspath_aggregate (struct aspath *as1, struct aspath *as2)
{
int i;
int minlen;
int match;
int from;
struct assegment *seg1 = as1->segments;
struct assegment *seg2 = as2->segments;
struct aspath *aspath = NULL;
struct assegment *asset;
struct assegment *prevseg = NULL;
match = 0;
minlen = 0;
aspath = NULL;
asset = NULL;
/* First of all check common leading sequence. */
while (seg1 && seg2)
{
/* Check segment type. */
if (seg1->type != seg2->type)
break;
/* Minimum segment length. */
minlen = min (seg1->length, seg2->length);
for (match = 0; match < minlen; match++)
if (seg1->as[match] != seg2->as[match])
break;
if (match)
{
struct assegment *seg = assegment_new (seg1->type, 0);
seg = assegment_append_asns (seg, seg1->as, match);
if (! aspath)
{
aspath = aspath_new ();
aspath->segments = seg;
}
else
prevseg->next = seg;
prevseg = seg;
}
if (match != minlen || match != seg1->length
|| seg1->length != seg2->length)
break;
/* We are moving on to the next segment to reset match */
else
match = 0;
seg1 = seg1->next;
seg2 = seg2->next;
}
if (! aspath)
aspath = aspath_new();
/* Make as-set using rest of all information. */
from = match;
while (seg1)
{
for (i = from; i < seg1->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg1->as[i]);
from = 0;
seg1 = seg1->next;
}
from = match;
while (seg2)
{
for (i = from; i < seg2->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg2->as[i]);
from = 0;
seg2 = seg2->next;
}
assegment_normalise (aspath->segments);
aspath_str_update (aspath);
return aspath;
}
|
DoS
| 0
|
aspath_aggregate (struct aspath *as1, struct aspath *as2)
{
int i;
int minlen;
int match;
int from;
struct assegment *seg1 = as1->segments;
struct assegment *seg2 = as2->segments;
struct aspath *aspath = NULL;
struct assegment *asset;
struct assegment *prevseg = NULL;
match = 0;
minlen = 0;
aspath = NULL;
asset = NULL;
/* First of all check common leading sequence. */
while (seg1 && seg2)
{
/* Check segment type. */
if (seg1->type != seg2->type)
break;
/* Minimum segment length. */
minlen = min (seg1->length, seg2->length);
for (match = 0; match < minlen; match++)
if (seg1->as[match] != seg2->as[match])
break;
if (match)
{
struct assegment *seg = assegment_new (seg1->type, 0);
seg = assegment_append_asns (seg, seg1->as, match);
if (! aspath)
{
aspath = aspath_new ();
aspath->segments = seg;
}
else
prevseg->next = seg;
prevseg = seg;
}
if (match != minlen || match != seg1->length
|| seg1->length != seg2->length)
break;
/* We are moving on to the next segment to reset match */
else
match = 0;
seg1 = seg1->next;
seg2 = seg2->next;
}
if (! aspath)
aspath = aspath_new();
/* Make as-set using rest of all information. */
from = match;
while (seg1)
{
for (i = from; i < seg1->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg1->as[i]);
from = 0;
seg1 = seg1->next;
}
from = match;
while (seg2)
{
for (i = from; i < seg2->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg2->as[i]);
from = 0;
seg2 = seg2->next;
}
assegment_normalise (aspath->segments);
aspath_str_update (aspath);
return aspath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,232
|
aspath_aggregate_as_set_add (struct aspath *aspath, struct assegment *asset,
as_t as)
{
int i;
/* If this is first AS set member, create new as-set segment. */
if (asset == NULL)
{
asset = assegment_new (AS_SET, 1);
if (! aspath->segments)
aspath->segments = asset;
else
{
struct assegment *seg = aspath->segments;
while (seg->next)
seg = seg->next;
seg->next = asset;
}
asset->type = AS_SET;
asset->length = 1;
asset->as[0] = as;
}
else
{
/* Check this AS value already exists or not. */
for (i = 0; i < asset->length; i++)
if (asset->as[i] == as)
return asset;
asset->length++;
asset->as = XREALLOC (MTYPE_AS_SEG_DATA, asset->as,
asset->length * AS_VALUE_SIZE);
asset->as[asset->length - 1] = as;
}
return asset;
}
|
DoS
| 0
|
aspath_aggregate_as_set_add (struct aspath *aspath, struct assegment *asset,
as_t as)
{
int i;
/* If this is first AS set member, create new as-set segment. */
if (asset == NULL)
{
asset = assegment_new (AS_SET, 1);
if (! aspath->segments)
aspath->segments = asset;
else
{
struct assegment *seg = aspath->segments;
while (seg->next)
seg = seg->next;
seg->next = asset;
}
asset->type = AS_SET;
asset->length = 1;
asset->as[0] = as;
}
else
{
/* Check this AS value already exists or not. */
for (i = 0; i < asset->length; i++)
if (asset->as[i] == as)
return asset;
asset->length++;
asset->as = XREALLOC (MTYPE_AS_SEG_DATA, asset->as,
asset->length * AS_VALUE_SIZE);
asset->as[asset->length - 1] = as;
}
return asset;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,233
|
aspath_aggregate_mpath (struct aspath *as1, struct aspath *as2)
{
int i;
int minlen;
int match;
int from1,from2;
struct assegment *seg1 = as1->segments;
struct assegment *seg2 = as2->segments;
struct aspath *aspath = NULL;
struct assegment *asset;
struct assegment *prevseg = NULL;
match = 0;
minlen = 0;
aspath = NULL;
asset = NULL;
/* First of all check common leading sequence. */
while (seg1 && seg2)
{
/* Check segment type. */
if (seg1->type != seg2->type)
break;
/* Minimum segment length. */
minlen = min (seg1->length, seg2->length);
for (match = 0; match < minlen; match++)
if (seg1->as[match] != seg2->as[match])
break;
if (match)
{
struct assegment *seg = assegment_new (seg1->type, 0);
seg = assegment_append_asns (seg, seg1->as, match);
if (! aspath)
{
aspath = aspath_new ();
aspath->segments = seg;
}
else
prevseg->next = seg;
prevseg = seg;
}
if (match != minlen || match != seg1->length
|| seg1->length != seg2->length)
break;
seg1 = seg1->next;
seg2 = seg2->next;
}
if (! aspath)
aspath = aspath_new();
/* Make as-set using rest of all information. */
from1 = from2 = match;
while (seg1 || seg2)
{
if (seg1)
{
if (seg1->type == AS_SEQUENCE)
{
asset = aspath_aggregate_as_set_add (aspath, asset, seg1->as[from1]);
from1++;
if (from1 >= seg1->length)
{
from1 = 0;
seg1 = seg1->next;
}
}
else
{
for (i = from1; i < seg1->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg1->as[i]);
from1 = 0;
seg1 = seg1->next;
}
}
if (seg2)
{
if (seg2->type == AS_SEQUENCE)
{
asset = aspath_aggregate_as_set_add (aspath, asset, seg2->as[from2]);
from2++;
if (from2 >= seg2->length)
{
from2 = 0;
seg2 = seg2->next;
}
}
else
{
for (i = from2; i < seg2->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg2->as[i]);
from2 = 0;
seg2 = seg2->next;
}
}
if (asset->length == 1)
asset->type = AS_SEQUENCE;
asset = NULL;
}
assegment_normalise (aspath->segments);
aspath_str_update (aspath);
return aspath;
}
|
DoS
| 0
|
aspath_aggregate_mpath (struct aspath *as1, struct aspath *as2)
{
int i;
int minlen;
int match;
int from1,from2;
struct assegment *seg1 = as1->segments;
struct assegment *seg2 = as2->segments;
struct aspath *aspath = NULL;
struct assegment *asset;
struct assegment *prevseg = NULL;
match = 0;
minlen = 0;
aspath = NULL;
asset = NULL;
/* First of all check common leading sequence. */
while (seg1 && seg2)
{
/* Check segment type. */
if (seg1->type != seg2->type)
break;
/* Minimum segment length. */
minlen = min (seg1->length, seg2->length);
for (match = 0; match < minlen; match++)
if (seg1->as[match] != seg2->as[match])
break;
if (match)
{
struct assegment *seg = assegment_new (seg1->type, 0);
seg = assegment_append_asns (seg, seg1->as, match);
if (! aspath)
{
aspath = aspath_new ();
aspath->segments = seg;
}
else
prevseg->next = seg;
prevseg = seg;
}
if (match != minlen || match != seg1->length
|| seg1->length != seg2->length)
break;
seg1 = seg1->next;
seg2 = seg2->next;
}
if (! aspath)
aspath = aspath_new();
/* Make as-set using rest of all information. */
from1 = from2 = match;
while (seg1 || seg2)
{
if (seg1)
{
if (seg1->type == AS_SEQUENCE)
{
asset = aspath_aggregate_as_set_add (aspath, asset, seg1->as[from1]);
from1++;
if (from1 >= seg1->length)
{
from1 = 0;
seg1 = seg1->next;
}
}
else
{
for (i = from1; i < seg1->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg1->as[i]);
from1 = 0;
seg1 = seg1->next;
}
}
if (seg2)
{
if (seg2->type == AS_SEQUENCE)
{
asset = aspath_aggregate_as_set_add (aspath, asset, seg2->as[from2]);
from2++;
if (from2 >= seg2->length)
{
from2 = 0;
seg2 = seg2->next;
}
}
else
{
for (i = from2; i < seg2->length; i++)
asset = aspath_aggregate_as_set_add (aspath, asset, seg2->as[i]);
from2 = 0;
seg2 = seg2->next;
}
}
if (asset->length == 1)
asset->type = AS_SEQUENCE;
asset = NULL;
}
assegment_normalise (aspath->segments);
aspath_str_update (aspath);
return aspath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,234
|
aspath_as_add (struct aspath *as, as_t asno)
{
struct assegment *seg = as->segments;
if (!seg)
return;
/* Last segment search procedure. */
while (seg->next)
seg = seg->next;
assegment_append_asns (seg, &asno, 1);
}
|
DoS
| 0
|
aspath_as_add (struct aspath *as, as_t asno)
{
struct assegment *seg = as->segments;
if (!seg)
return;
/* Last segment search procedure. */
while (seg->next)
seg = seg->next;
assegment_append_asns (seg, &asno, 1);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,235
|
aspath_cmp (const void *arg1, const void *arg2)
{
const struct assegment *seg1 = ((const struct aspath *)arg1)->segments;
const struct assegment *seg2 = ((const struct aspath *)arg2)->segments;
while (seg1 || seg2)
{
int i;
if ((!seg1 && seg2) || (seg1 && !seg2))
return 0;
if (seg1->type != seg2->type)
return 0;
if (seg1->length != seg2->length)
return 0;
for (i = 0; i < seg1->length; i++)
if (seg1->as[i] != seg2->as[i])
return 0;
seg1 = seg1->next;
seg2 = seg2->next;
}
return 1;
}
|
DoS
| 0
|
aspath_cmp (const void *arg1, const void *arg2)
{
const struct assegment *seg1 = ((const struct aspath *)arg1)->segments;
const struct assegment *seg2 = ((const struct aspath *)arg2)->segments;
while (seg1 || seg2)
{
int i;
if ((!seg1 && seg2) || (seg1 && !seg2))
return 0;
if (seg1->type != seg2->type)
return 0;
if (seg1->length != seg2->length)
return 0;
for (i = 0; i < seg1->length; i++)
if (seg1->as[i] != seg2->as[i])
return 0;
seg1 = seg1->next;
seg2 = seg2->next;
}
return 1;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,236
|
aspath_cmp_left (const struct aspath *aspath1, const struct aspath *aspath2)
{
const struct assegment *seg1;
const struct assegment *seg2;
if (!(aspath1 && aspath2))
return 0;
seg1 = aspath1->segments;
seg2 = aspath2->segments;
/* If both paths are originated in this AS then we do want to compare MED */
if (!seg1 && !seg2)
return 1;
/* find first non-confed segments for each */
while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
|| (seg1->type == AS_CONFED_SET)))
seg1 = seg1->next;
while (seg2 && ((seg2->type == AS_CONFED_SEQUENCE)
|| (seg2->type == AS_CONFED_SET)))
seg2 = seg2->next;
/* Check as1's */
if (!(seg1 && seg2
&& (seg1->type == AS_SEQUENCE) && (seg2->type == AS_SEQUENCE)))
return 0;
if (seg1->as[0] == seg2->as[0])
return 1;
return 0;
}
|
DoS
| 0
|
aspath_cmp_left (const struct aspath *aspath1, const struct aspath *aspath2)
{
const struct assegment *seg1;
const struct assegment *seg2;
if (!(aspath1 && aspath2))
return 0;
seg1 = aspath1->segments;
seg2 = aspath2->segments;
/* If both paths are originated in this AS then we do want to compare MED */
if (!seg1 && !seg2)
return 1;
/* find first non-confed segments for each */
while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
|| (seg1->type == AS_CONFED_SET)))
seg1 = seg1->next;
while (seg2 && ((seg2->type == AS_CONFED_SEQUENCE)
|| (seg2->type == AS_CONFED_SET)))
seg2 = seg2->next;
/* Check as1's */
if (!(seg1 && seg2
&& (seg1->type == AS_SEQUENCE) && (seg2->type == AS_SEQUENCE)))
return 0;
if (seg1->as[0] == seg2->as[0])
return 1;
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,237
|
aspath_cmp_left_confed (const struct aspath *aspath1, const struct aspath *aspath2)
{
if (! (aspath1 && aspath2) )
return 0;
if ( !(aspath1->segments && aspath2->segments) )
return 0;
if ( (aspath1->segments->type != AS_CONFED_SEQUENCE)
|| (aspath2->segments->type != AS_CONFED_SEQUENCE) )
return 0;
if (aspath1->segments->as[0] == aspath2->segments->as[0])
return 1;
return 0;
}
|
DoS
| 0
|
aspath_cmp_left_confed (const struct aspath *aspath1, const struct aspath *aspath2)
{
if (! (aspath1 && aspath2) )
return 0;
if ( !(aspath1->segments && aspath2->segments) )
return 0;
if ( (aspath1->segments->type != AS_CONFED_SEQUENCE)
|| (aspath2->segments->type != AS_CONFED_SEQUENCE) )
return 0;
if (aspath1->segments->as[0] == aspath2->segments->as[0])
return 1;
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,238
|
aspath_confed_check (struct aspath *aspath)
{
struct assegment *seg;
if ( !(aspath && aspath->segments) )
return 0;
seg = aspath->segments;
while (seg)
{
if (seg->type == AS_CONFED_SET || seg->type == AS_CONFED_SEQUENCE)
return 1;
seg = seg->next;
}
return 0;
}
|
DoS
| 0
|
aspath_confed_check (struct aspath *aspath)
{
struct assegment *seg;
if ( !(aspath && aspath->segments) )
return 0;
seg = aspath->segments;
while (seg)
{
if (seg->type == AS_CONFED_SET || seg->type == AS_CONFED_SEQUENCE)
return 1;
seg = seg->next;
}
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,239
|
aspath_count_confeds (struct aspath *aspath)
{
int count = 0;
struct assegment *seg = aspath->segments;
while (seg)
{
if (seg->type == AS_CONFED_SEQUENCE)
count += seg->length;
else if (seg->type == AS_CONFED_SET)
count++;
seg = seg->next;
}
return count;
}
|
DoS
| 0
|
aspath_count_confeds (struct aspath *aspath)
{
int count = 0;
struct assegment *seg = aspath->segments;
while (seg)
{
if (seg->type == AS_CONFED_SEQUENCE)
count += seg->length;
else if (seg->type == AS_CONFED_SET)
count++;
seg = seg->next;
}
return count;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,240
|
aspath_count_hops (const struct aspath *aspath)
{
int count = 0;
struct assegment *seg = aspath->segments;
while (seg)
{
if (seg->type == AS_SEQUENCE)
count += seg->length;
else if (seg->type == AS_SET)
count++;
seg = seg->next;
}
return count;
}
|
DoS
| 0
|
aspath_count_hops (const struct aspath *aspath)
{
int count = 0;
struct assegment *seg = aspath->segments;
while (seg)
{
if (seg->type == AS_SEQUENCE)
count += seg->length;
else if (seg->type == AS_SET)
count++;
seg = seg->next;
}
return count;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,241
|
aspath_delete_confed_seq (struct aspath *aspath)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
return aspath;
seg = aspath->segments;
/* "if the first path segment of the AS_PATH is
* of type AS_CONFED_SEQUENCE,"
*/
if (aspath->segments->type != AS_CONFED_SEQUENCE)
return aspath;
/* "... that segment and any immediately following segments
* of the type AS_CONFED_SET or AS_CONFED_SEQUENCE are removed
* from the AS_PATH attribute,"
*/
while (seg &&
(seg->type == AS_CONFED_SEQUENCE || seg->type == AS_CONFED_SET))
{
aspath->segments = seg->next;
assegment_free (seg);
seg = aspath->segments;
}
aspath_str_update (aspath);
return aspath;
}
|
DoS
| 0
|
aspath_delete_confed_seq (struct aspath *aspath)
{
struct assegment *seg;
if (!(aspath && aspath->segments))
return aspath;
seg = aspath->segments;
/* "if the first path segment of the AS_PATH is
* of type AS_CONFED_SEQUENCE,"
*/
if (aspath->segments->type != AS_CONFED_SEQUENCE)
return aspath;
/* "... that segment and any immediately following segments
* of the type AS_CONFED_SET or AS_CONFED_SEQUENCE are removed
* from the AS_PATH attribute,"
*/
while (seg &&
(seg->type == AS_CONFED_SEQUENCE || seg->type == AS_CONFED_SET))
{
aspath->segments = seg->next;
assegment_free (seg);
seg = aspath->segments;
}
aspath_str_update (aspath);
return aspath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,242
|
aspath_delimiter_char (u_char type, u_char which)
{
int i;
struct
{
int type;
char start;
char end;
} aspath_delim_char [] =
{
{ AS_SET, '{', '}' },
{ AS_CONFED_SET, '[', ']' },
{ AS_CONFED_SEQUENCE, '(', ')' },
{ 0 }
};
for (i = 0; aspath_delim_char[i].type != 0; i++)
{
if (aspath_delim_char[i].type == type)
{
if (which == AS_SEG_START)
return aspath_delim_char[i].start;
else if (which == AS_SEG_END)
return aspath_delim_char[i].end;
}
}
return ' ';
}
|
DoS
| 0
|
aspath_delimiter_char (u_char type, u_char which)
{
int i;
struct
{
int type;
char start;
char end;
} aspath_delim_char [] =
{
{ AS_SET, '{', '}' },
{ AS_CONFED_SET, '[', ']' },
{ AS_CONFED_SEQUENCE, '(', ')' },
{ 0 }
};
for (i = 0; aspath_delim_char[i].type != 0; i++)
{
if (aspath_delim_char[i].type == type)
{
if (which == AS_SEG_START)
return aspath_delim_char[i].start;
else if (which == AS_SEG_END)
return aspath_delim_char[i].end;
}
}
return ' ';
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,243
|
aspath_empty (void)
{
return aspath_parse (NULL, 0, 1); /* 32Bit ;-) */
}
|
DoS
| 0
|
aspath_empty (void)
{
return aspath_parse (NULL, 0, 1); /* 32Bit ;-) */
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,244
|
aspath_empty_get (void)
{
struct aspath *aspath;
aspath = aspath_new ();
aspath_make_str_count (aspath);
return aspath;
}
|
DoS
| 0
|
aspath_empty_get (void)
{
struct aspath *aspath;
aspath = aspath_new ();
aspath_make_str_count (aspath);
return aspath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,245
|
aspath_filter_exclude (struct aspath * source, struct aspath * exclude_list)
{
struct assegment * srcseg, * exclseg, * lastseg;
struct aspath * newpath;
newpath = aspath_new();
lastseg = NULL;
for (srcseg = source->segments; srcseg; srcseg = srcseg->next)
{
unsigned i, y, newlen = 0, done = 0, skip_as;
struct assegment * newseg;
/* Find out, how much ASns are we going to pick from this segment.
* We can't perform filtering right inline, because the size of
* the new segment isn't known at the moment yet.
*/
for (i = 0; i < srcseg->length; i++)
{
skip_as = 0;
for (exclseg = exclude_list->segments; exclseg && !skip_as; exclseg = exclseg->next)
for (y = 0; y < exclseg->length; y++)
if (srcseg->as[i] == exclseg->as[y])
{
skip_as = 1;
break;
}
if (!skip_as)
newlen++;
}
/* newlen is now the number of ASns to copy */
if (!newlen)
continue;
/* Actual copying. Allocate memory and iterate once more, performing filtering. */
newseg = assegment_new (srcseg->type, newlen);
for (i = 0; i < srcseg->length; i++)
{
skip_as = 0;
for (exclseg = exclude_list->segments; exclseg && !skip_as; exclseg = exclseg->next)
for (y = 0; y < exclseg->length; y++)
if (srcseg->as[i] == exclseg->as[y])
{
skip_as = 1;
break;
}
if (skip_as)
continue;
newseg->as[done++] = srcseg->as[i];
}
/* At his point newlen must be equal to done, and both must be positive. Append
* the filtered segment to the gross result. */
if (!lastseg)
newpath->segments = newseg;
else
lastseg->next = newseg;
lastseg = newseg;
}
aspath_str_update (newpath);
/* We are happy returning even an empty AS_PATH, because the administrator
* might expect this very behaviour. There's a mean to avoid this, if necessary,
* by having a match rule against certain AS_PATH regexps in the route-map index.
*/
aspath_free (source);
return newpath;
}
|
DoS
| 0
|
aspath_filter_exclude (struct aspath * source, struct aspath * exclude_list)
{
struct assegment * srcseg, * exclseg, * lastseg;
struct aspath * newpath;
newpath = aspath_new();
lastseg = NULL;
for (srcseg = source->segments; srcseg; srcseg = srcseg->next)
{
unsigned i, y, newlen = 0, done = 0, skip_as;
struct assegment * newseg;
/* Find out, how much ASns are we going to pick from this segment.
* We can't perform filtering right inline, because the size of
* the new segment isn't known at the moment yet.
*/
for (i = 0; i < srcseg->length; i++)
{
skip_as = 0;
for (exclseg = exclude_list->segments; exclseg && !skip_as; exclseg = exclseg->next)
for (y = 0; y < exclseg->length; y++)
if (srcseg->as[i] == exclseg->as[y])
{
skip_as = 1;
break;
}
if (!skip_as)
newlen++;
}
/* newlen is now the number of ASns to copy */
if (!newlen)
continue;
/* Actual copying. Allocate memory and iterate once more, performing filtering. */
newseg = assegment_new (srcseg->type, newlen);
for (i = 0; i < srcseg->length; i++)
{
skip_as = 0;
for (exclseg = exclude_list->segments; exclseg && !skip_as; exclseg = exclseg->next)
for (y = 0; y < exclseg->length; y++)
if (srcseg->as[i] == exclseg->as[y])
{
skip_as = 1;
break;
}
if (skip_as)
continue;
newseg->as[done++] = srcseg->as[i];
}
/* At his point newlen must be equal to done, and both must be positive. Append
* the filtered segment to the gross result. */
if (!lastseg)
newpath->segments = newseg;
else
lastseg->next = newseg;
lastseg = newseg;
}
aspath_str_update (newpath);
/* We are happy returning even an empty AS_PATH, because the administrator
* might expect this very behaviour. There's a mean to avoid this, if necessary,
* by having a match rule against certain AS_PATH regexps in the route-map index.
*/
aspath_free (source);
return newpath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,246
|
aspath_finish (void)
{
hash_clean (ashash, (void (*)(void *))aspath_free);
hash_free (ashash);
ashash = NULL;
if (snmp_stream)
stream_free (snmp_stream);
}
|
DoS
| 0
|
aspath_finish (void)
{
hash_clean (ashash, (void (*)(void *))aspath_free);
hash_free (ashash);
ashash = NULL;
if (snmp_stream)
stream_free (snmp_stream);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,247
|
aspath_firstas_check (struct aspath *aspath, as_t asno)
{
if ( (aspath == NULL) || (aspath->segments == NULL) )
return 0;
if (aspath->segments
&& (aspath->segments->type == AS_SEQUENCE)
&& (aspath->segments->as[0] == asno ))
return 1;
return 0;
}
|
DoS
| 0
|
aspath_firstas_check (struct aspath *aspath, as_t asno)
{
if ( (aspath == NULL) || (aspath->segments == NULL) )
return 0;
if (aspath->segments
&& (aspath->segments->type == AS_SEQUENCE)
&& (aspath->segments->as[0] == asno ))
return 1;
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,248
|
aspath_free (struct aspath *aspath)
{
if (!aspath)
return;
if (aspath->segments)
assegment_free_all (aspath->segments);
if (aspath->str)
XFREE (MTYPE_AS_STR, aspath->str);
XFREE (MTYPE_AS_PATH, aspath);
}
|
DoS
| 0
|
aspath_free (struct aspath *aspath)
{
if (!aspath)
return;
if (aspath->segments)
assegment_free_all (aspath->segments);
if (aspath->str)
XFREE (MTYPE_AS_STR, aspath->str);
XFREE (MTYPE_AS_PATH, aspath);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,249
|
aspath_gettoken (const char *buf, enum as_token *token, u_long *asno)
{
const char *p = buf;
/* Skip seperators (space for sequences, ',' for sets). */
while (isspace ((int) *p) || *p == ',')
p++;
/* Check the end of the string and type specify characters
(e.g. {}()). */
switch (*p)
{
case '\0':
return NULL;
case '{':
*token = as_token_set_start;
p++;
return p;
case '}':
*token = as_token_set_end;
p++;
return p;
case '(':
*token = as_token_confed_seq_start;
p++;
return p;
case ')':
*token = as_token_confed_seq_end;
p++;
return p;
case '[':
*token = as_token_confed_set_start;
p++;
return p;
case ']':
*token = as_token_confed_set_end;
p++;
return p;
}
/* Check actual AS value. */
if (isdigit ((int) *p))
{
as_t asval;
*token = as_token_asval;
asval = (*p - '0');
p++;
while (isdigit ((int) *p))
{
asval *= 10;
asval += (*p - '0');
p++;
}
*asno = asval;
return p;
}
/* There is no match then return unknown token. */
*token = as_token_unknown;
return p++;
}
|
DoS
| 0
|
aspath_gettoken (const char *buf, enum as_token *token, u_long *asno)
{
const char *p = buf;
/* Skip seperators (space for sequences, ',' for sets). */
while (isspace ((int) *p) || *p == ',')
p++;
/* Check the end of the string and type specify characters
(e.g. {}()). */
switch (*p)
{
case '\0':
return NULL;
case '{':
*token = as_token_set_start;
p++;
return p;
case '}':
*token = as_token_set_end;
p++;
return p;
case '(':
*token = as_token_confed_seq_start;
p++;
return p;
case ')':
*token = as_token_confed_seq_end;
p++;
return p;
case '[':
*token = as_token_confed_set_start;
p++;
return p;
case ']':
*token = as_token_confed_set_end;
p++;
return p;
}
/* Check actual AS value. */
if (isdigit ((int) *p))
{
as_t asval;
*token = as_token_asval;
asval = (*p - '0');
p++;
while (isdigit ((int) *p))
{
asval *= 10;
asval += (*p - '0');
p++;
}
*asno = asval;
return p;
}
/* There is no match then return unknown token. */
*token = as_token_unknown;
return p++;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,250
|
aspath_has_as4 (struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
unsigned int i;
while (seg)
{
for (i = 0; i < seg->length; i++)
if (seg->as[i] > BGP_AS_MAX)
return 1;
seg = seg->next;
}
return 0;
}
|
DoS
| 0
|
aspath_has_as4 (struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
unsigned int i;
while (seg)
{
for (i = 0; i < seg->length; i++)
if (seg->as[i] > BGP_AS_MAX)
return 1;
seg = seg->next;
}
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,251
|
aspath_hash_alloc (void *arg)
{
const struct aspath *aspath = arg;
struct aspath *new;
/* Malformed AS path value. */
assert (aspath->str);
if (! aspath->str)
return NULL;
/* New aspath structure is needed. */
new = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
/* Reuse segments and string representation */
new->refcnt = 0;
new->segments = aspath->segments;
new->str = aspath->str;
new->str_len = aspath->str_len;
return new;
}
|
DoS
| 0
|
aspath_hash_alloc (void *arg)
{
const struct aspath *aspath = arg;
struct aspath *new;
/* Malformed AS path value. */
assert (aspath->str);
if (! aspath->str)
return NULL;
/* New aspath structure is needed. */
new = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
/* Reuse segments and string representation */
new->refcnt = 0;
new->segments = aspath->segments;
new->str = aspath->str;
new->str_len = aspath->str_len;
return new;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,252
|
aspath_highest (struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
as_t highest = 0;
unsigned int i;
while (seg)
{
for (i = 0; i < seg->length; i++)
if (seg->as[i] > highest
&& !BGP_AS_IS_PRIVATE(seg->as[i]))
highest = seg->as[i];
seg = seg->next;
}
return highest;
}
|
DoS
| 0
|
aspath_highest (struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
as_t highest = 0;
unsigned int i;
while (seg)
{
for (i = 0; i < seg->length; i++)
if (seg->as[i] > highest
&& !BGP_AS_IS_PRIVATE(seg->as[i]))
highest = seg->as[i];
seg = seg->next;
}
return highest;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,253
|
aspath_intern (struct aspath *aspath)
{
struct aspath *find;
/* Assert this AS path structure is not interned and has the string
representation built. */
assert (aspath->refcnt == 0);
assert (aspath->str);
/* Check AS path hash. */
find = hash_get (ashash, aspath, hash_alloc_intern);
if (find != aspath)
aspath_free (aspath);
find->refcnt++;
return find;
}
|
DoS
| 0
|
aspath_intern (struct aspath *aspath)
{
struct aspath *find;
/* Assert this AS path structure is not interned and has the string
representation built. */
assert (aspath->refcnt == 0);
assert (aspath->str);
/* Check AS path hash. */
find = hash_get (ashash, aspath, hash_alloc_intern);
if (find != aspath)
aspath_free (aspath);
find->refcnt++;
return find;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,254
|
aspath_key_make (void *p)
{
struct aspath *aspath = (struct aspath *) p;
unsigned int key = 0;
if (!aspath->str)
aspath_str_update (aspath);
key = jhash (aspath->str, aspath->str_len, 2334325);
return key;
}
|
DoS
| 0
|
aspath_key_make (void *p)
{
struct aspath *aspath = (struct aspath *) p;
unsigned int key = 0;
if (!aspath->str)
aspath_str_update (aspath);
key = jhash (aspath->str, aspath->str_len, 2334325);
return key;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,255
|
aspath_left_confed_check (struct aspath *aspath)
{
if ( !(aspath && aspath->segments) )
return 0;
if ( (aspath->segments->type == AS_CONFED_SEQUENCE)
|| (aspath->segments->type == AS_CONFED_SET) )
return 1;
return 0;
}
|
DoS
| 0
|
aspath_left_confed_check (struct aspath *aspath)
{
if ( !(aspath && aspath->segments) )
return 0;
if ( (aspath->segments->type == AS_CONFED_SEQUENCE)
|| (aspath->segments->type == AS_CONFED_SET) )
return 1;
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,256
|
aspath_leftmost (struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
as_t leftmost = 0;
if (seg && seg->length && seg->type == AS_SEQUENCE)
leftmost = seg->as[0];
return leftmost;
}
|
DoS
| 0
|
aspath_leftmost (struct aspath *aspath)
{
struct assegment *seg = aspath->segments;
as_t leftmost = 0;
if (seg && seg->length && seg->type == AS_SEQUENCE)
leftmost = seg->as[0];
return leftmost;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,257
|
aspath_loop_check (struct aspath *aspath, as_t asno)
{
struct assegment *seg;
int count = 0;
if ( (aspath == NULL) || (aspath->segments == NULL) )
return 0;
seg = aspath->segments;
while (seg)
{
int i;
for (i = 0; i < seg->length; i++)
if (seg->as[i] == asno)
count++;
seg = seg->next;
}
return count;
}
|
DoS
| 0
|
aspath_loop_check (struct aspath *aspath, as_t asno)
{
struct assegment *seg;
int count = 0;
if ( (aspath == NULL) || (aspath->segments == NULL) )
return 0;
seg = aspath->segments;
while (seg)
{
int i;
for (i = 0; i < seg->length; i++)
if (seg->as[i] == asno)
count++;
seg = seg->next;
}
return count;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,258
|
aspath_make_str_count (struct aspath *as)
{
struct assegment *seg;
int str_size;
int len = 0;
char *str_buf;
/* Empty aspath. */
if (!as->segments)
{
as->str = XMALLOC (MTYPE_AS_STR, 1);
as->str[0] = '\0';
as->str_len = 0;
return;
}
seg = as->segments;
/* ASN takes 5 to 10 chars plus seperator, see below.
* If there is one differing segment type, we need an additional
* 2 chars for segment delimiters, and the final '\0'.
* Hopefully this is large enough to avoid hitting the realloc
* code below for most common sequences.
*
* This was changed to 10 after the well-known BGP assertion, which
* had hit some parts of the Internet in May of 2009.
*/
#define ASN_STR_LEN (10 + 1)
str_size = MAX (assegment_count_asns (seg, 0) * ASN_STR_LEN + 2 + 1,
ASPATH_STR_DEFAULT_LEN);
str_buf = XMALLOC (MTYPE_AS_STR, str_size);
while (seg)
{
int i;
char seperator;
/* Check AS type validity. Set seperator for segment */
switch (seg->type)
{
case AS_SET:
case AS_CONFED_SET:
seperator = ',';
break;
case AS_SEQUENCE:
case AS_CONFED_SEQUENCE:
seperator = ' ';
break;
default:
XFREE (MTYPE_AS_STR, str_buf);
as->str = NULL;
as->str_len = 0;
return;
}
/* We might need to increase str_buf, particularly if path has
* differing segments types, our initial guesstimate above will
* have been wrong. Need 10 chars for ASN, a seperator each and
* potentially two segment delimiters, plus a space between each
* segment and trailing zero.
*
* This definitely didn't work with the value of 5 bytes and
* 32-bit ASNs.
*/
#define SEGMENT_STR_LEN(X) (((X)->length * ASN_STR_LEN) + 2 + 1 + 1)
if ( (len + SEGMENT_STR_LEN(seg)) > str_size)
{
str_size = len + SEGMENT_STR_LEN(seg);
str_buf = XREALLOC (MTYPE_AS_STR, str_buf, str_size);
}
#undef ASN_STR_LEN
#undef SEGMENT_STR_LEN
if (seg->type != AS_SEQUENCE)
len += snprintf (str_buf + len, str_size - len,
"%c",
aspath_delimiter_char (seg->type, AS_SEG_START));
/* write out the ASNs, with their seperators, bar the last one*/
for (i = 0; i < seg->length; i++)
{
len += snprintf (str_buf + len, str_size - len, "%u", seg->as[i]);
if (i < (seg->length - 1))
len += snprintf (str_buf + len, str_size - len, "%c", seperator);
}
if (seg->type != AS_SEQUENCE)
len += snprintf (str_buf + len, str_size - len, "%c",
aspath_delimiter_char (seg->type, AS_SEG_END));
if (seg->next)
len += snprintf (str_buf + len, str_size - len, " ");
seg = seg->next;
}
assert (len < str_size);
str_buf[len] = '\0';
as->str = str_buf;
as->str_len = len;
return;
}
|
DoS
| 0
|
aspath_make_str_count (struct aspath *as)
{
struct assegment *seg;
int str_size;
int len = 0;
char *str_buf;
/* Empty aspath. */
if (!as->segments)
{
as->str = XMALLOC (MTYPE_AS_STR, 1);
as->str[0] = '\0';
as->str_len = 0;
return;
}
seg = as->segments;
/* ASN takes 5 to 10 chars plus seperator, see below.
* If there is one differing segment type, we need an additional
* 2 chars for segment delimiters, and the final '\0'.
* Hopefully this is large enough to avoid hitting the realloc
* code below for most common sequences.
*
* This was changed to 10 after the well-known BGP assertion, which
* had hit some parts of the Internet in May of 2009.
*/
#define ASN_STR_LEN (10 + 1)
str_size = MAX (assegment_count_asns (seg, 0) * ASN_STR_LEN + 2 + 1,
ASPATH_STR_DEFAULT_LEN);
str_buf = XMALLOC (MTYPE_AS_STR, str_size);
while (seg)
{
int i;
char seperator;
/* Check AS type validity. Set seperator for segment */
switch (seg->type)
{
case AS_SET:
case AS_CONFED_SET:
seperator = ',';
break;
case AS_SEQUENCE:
case AS_CONFED_SEQUENCE:
seperator = ' ';
break;
default:
XFREE (MTYPE_AS_STR, str_buf);
as->str = NULL;
as->str_len = 0;
return;
}
/* We might need to increase str_buf, particularly if path has
* differing segments types, our initial guesstimate above will
* have been wrong. Need 10 chars for ASN, a seperator each and
* potentially two segment delimiters, plus a space between each
* segment and trailing zero.
*
* This definitely didn't work with the value of 5 bytes and
* 32-bit ASNs.
*/
#define SEGMENT_STR_LEN(X) (((X)->length * ASN_STR_LEN) + 2 + 1 + 1)
if ( (len + SEGMENT_STR_LEN(seg)) > str_size)
{
str_size = len + SEGMENT_STR_LEN(seg);
str_buf = XREALLOC (MTYPE_AS_STR, str_buf, str_size);
}
#undef ASN_STR_LEN
#undef SEGMENT_STR_LEN
if (seg->type != AS_SEQUENCE)
len += snprintf (str_buf + len, str_size - len,
"%c",
aspath_delimiter_char (seg->type, AS_SEG_START));
/* write out the ASNs, with their seperators, bar the last one*/
for (i = 0; i < seg->length; i++)
{
len += snprintf (str_buf + len, str_size - len, "%u", seg->as[i]);
if (i < (seg->length - 1))
len += snprintf (str_buf + len, str_size - len, "%c", seperator);
}
if (seg->type != AS_SEQUENCE)
len += snprintf (str_buf + len, str_size - len, "%c",
aspath_delimiter_char (seg->type, AS_SEG_END));
if (seg->next)
len += snprintf (str_buf + len, str_size - len, " ");
seg = seg->next;
}
assert (len < str_size);
str_buf[len] = '\0';
as->str = str_buf;
as->str_len = len;
return;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,259
|
aspath_merge (struct aspath *as1, struct aspath *as2)
{
struct assegment *last, *new;
if (! as1 || ! as2)
return NULL;
last = new = assegment_dup_all (as1->segments);
/* find the last valid segment */
while (last && last->next)
last = last->next;
last->next = as2->segments;
as2->segments = new;
aspath_str_update (as2);
return as2;
}
|
DoS
| 0
|
aspath_merge (struct aspath *as1, struct aspath *as2)
{
struct assegment *last, *new;
if (! as1 || ! as2)
return NULL;
last = new = assegment_dup_all (as1->segments);
/* find the last valid segment */
while (last && last->next)
last = last->next;
last->next = as2->segments;
as2->segments = new;
aspath_str_update (as2);
return as2;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,260
|
aspath_new (void)
{
return XCALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
}
|
DoS
| 0
|
aspath_new (void)
{
return XCALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,261
|
aspath_parse (struct stream *s, size_t length, int use32bit)
{
struct aspath as;
struct aspath *find;
/* If length is odd it's malformed AS path. */
/* Nit-picking: if (use32bit == 0) it is malformed if odd,
* otherwise its malformed when length is larger than 2 and (length-2)
* is not dividable by 4.
* But... this time we're lazy
*/
if (length % AS16_VALUE_SIZE )
return NULL;
memset (&as, 0, sizeof (struct aspath));
if (assegments_parse (s, length, &as.segments, use32bit) < 0)
return NULL;
/* If already same aspath exist then return it. */
find = hash_get (ashash, &as, aspath_hash_alloc);
/* bug! should not happen, let the daemon crash below */
assert (find);
/* if the aspath was already hashed free temporary memory. */
if (find->refcnt)
{
assegment_free_all (as.segments);
/* aspath_key_make() always updates the string */
XFREE (MTYPE_AS_STR, as.str);
}
find->refcnt++;
return find;
}
|
DoS
| 0
|
aspath_parse (struct stream *s, size_t length, int use32bit)
{
struct aspath as;
struct aspath *find;
/* If length is odd it's malformed AS path. */
/* Nit-picking: if (use32bit == 0) it is malformed if odd,
* otherwise its malformed when length is larger than 2 and (length-2)
* is not dividable by 4.
* But... this time we're lazy
*/
if (length % AS16_VALUE_SIZE )
return NULL;
memset (&as, 0, sizeof (struct aspath));
if (assegments_parse (s, length, &as.segments, use32bit) < 0)
return NULL;
/* If already same aspath exist then return it. */
find = hash_get (ashash, &as, aspath_hash_alloc);
/* bug! should not happen, let the daemon crash below */
assert (find);
/* if the aspath was already hashed free temporary memory. */
if (find->refcnt)
{
assegment_free_all (as.segments);
/* aspath_key_make() always updates the string */
XFREE (MTYPE_AS_STR, as.str);
}
find->refcnt++;
return find;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,262
|
aspath_prepend (struct aspath *as1, struct aspath *as2)
{
struct assegment *seg1;
struct assegment *seg2;
if (! as1 || ! as2)
return NULL;
seg1 = as1->segments;
seg2 = as2->segments;
/* If as2 is empty, only need to dupe as1's chain onto as2 */
if (seg2 == NULL)
{
as2->segments = assegment_dup_all (as1->segments);
aspath_str_update (as2);
return as2;
}
/* If as1 is empty AS, no prepending to do. */
if (seg1 == NULL)
return as2;
/* find the tail as1's segment chain. */
while (seg1 && seg1->next)
seg1 = seg1->next;
/* Delete any AS_CONFED_SEQUENCE segment from as2. */
if (seg1->type == AS_SEQUENCE && seg2->type == AS_CONFED_SEQUENCE)
as2 = aspath_delete_confed_seq (as2);
/* as2 may have been updated */
seg2 = as2->segments;
/* as2 may be empty now due to aspath_delete_confed_seq, recheck */
if (seg2 == NULL)
{
as2->segments = assegment_dup_all (as1->segments);
aspath_str_update (as2);
return as2;
}
/* Compare last segment type of as1 and first segment type of as2. */
if (seg1->type != seg2->type)
return aspath_merge (as1, as2);
if (seg1->type == AS_SEQUENCE)
{
/* We have two chains of segments, as1->segments and seg2,
* and we have to attach them together, merging the attaching
* segments together into one.
*
* 1. dupe as1->segments onto head of as2
* 2. merge seg2's asns onto last segment of this new chain
* 3. attach chain after seg2
*/
/* dupe as1 onto as2's head */
seg1 = as2->segments = assegment_dup_all (as1->segments);
/* refind the tail of as2, reusing seg1 */
while (seg1 && seg1->next)
seg1 = seg1->next;
/* merge the old head, seg2, into tail, seg1 */
seg1 = assegment_append_asns (seg1, seg2->as, seg2->length);
/* bypass the merged seg2, and attach any chain after it to
* chain descending from as2's head
*/
seg1->next = seg2->next;
/* seg2 is now referenceless and useless*/
assegment_free (seg2);
/* we've now prepended as1's segment chain to as2, merging
* the inbetween AS_SEQUENCE of seg2 in the process
*/
aspath_str_update (as2);
return as2;
}
else
{
/* AS_SET merge code is needed at here. */
return aspath_merge (as1, as2);
}
/* XXX: Ermmm, what if as1 has multiple segments?? */
/* Not reached */
}
|
DoS
| 0
|
aspath_prepend (struct aspath *as1, struct aspath *as2)
{
struct assegment *seg1;
struct assegment *seg2;
if (! as1 || ! as2)
return NULL;
seg1 = as1->segments;
seg2 = as2->segments;
/* If as2 is empty, only need to dupe as1's chain onto as2 */
if (seg2 == NULL)
{
as2->segments = assegment_dup_all (as1->segments);
aspath_str_update (as2);
return as2;
}
/* If as1 is empty AS, no prepending to do. */
if (seg1 == NULL)
return as2;
/* find the tail as1's segment chain. */
while (seg1 && seg1->next)
seg1 = seg1->next;
/* Delete any AS_CONFED_SEQUENCE segment from as2. */
if (seg1->type == AS_SEQUENCE && seg2->type == AS_CONFED_SEQUENCE)
as2 = aspath_delete_confed_seq (as2);
/* as2 may have been updated */
seg2 = as2->segments;
/* as2 may be empty now due to aspath_delete_confed_seq, recheck */
if (seg2 == NULL)
{
as2->segments = assegment_dup_all (as1->segments);
aspath_str_update (as2);
return as2;
}
/* Compare last segment type of as1 and first segment type of as2. */
if (seg1->type != seg2->type)
return aspath_merge (as1, as2);
if (seg1->type == AS_SEQUENCE)
{
/* We have two chains of segments, as1->segments and seg2,
* and we have to attach them together, merging the attaching
* segments together into one.
*
* 1. dupe as1->segments onto head of as2
* 2. merge seg2's asns onto last segment of this new chain
* 3. attach chain after seg2
*/
/* dupe as1 onto as2's head */
seg1 = as2->segments = assegment_dup_all (as1->segments);
/* refind the tail of as2, reusing seg1 */
while (seg1 && seg1->next)
seg1 = seg1->next;
/* merge the old head, seg2, into tail, seg1 */
seg1 = assegment_append_asns (seg1, seg2->as, seg2->length);
/* bypass the merged seg2, and attach any chain after it to
* chain descending from as2's head
*/
seg1->next = seg2->next;
/* seg2 is now referenceless and useless*/
assegment_free (seg2);
/* we've now prepended as1's segment chain to as2, merging
* the inbetween AS_SEQUENCE of seg2 in the process
*/
aspath_str_update (as2);
return as2;
}
else
{
/* AS_SET merge code is needed at here. */
return aspath_merge (as1, as2);
}
/* XXX: Ermmm, what if as1 has multiple segments?? */
/* Not reached */
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,263
|
aspath_print (struct aspath *as)
{
return (as ? as->str : NULL);
}
|
DoS
| 0
|
aspath_print (struct aspath *as)
{
return (as ? as->str : NULL);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,264
|
aspath_print_all_vty (struct vty *vty)
{
hash_iterate (ashash,
(void (*) (struct hash_backet *, void *))
aspath_show_all_iterator,
vty);
}
|
DoS
| 0
|
aspath_print_all_vty (struct vty *vty)
{
hash_iterate (ashash,
(void (*) (struct hash_backet *, void *))
aspath_show_all_iterator,
vty);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,265
|
aspath_print_vty (struct vty *vty, const char *format, struct aspath *as, const char * suffix)
{
assert (format);
vty_out (vty, format, as->str);
if (as->str_len && strlen (suffix))
vty_out (vty, "%s", suffix);
}
|
DoS
| 0
|
aspath_print_vty (struct vty *vty, const char *format, struct aspath *as, const char * suffix)
{
assert (format);
vty_out (vty, format, as->str);
if (as->str_len && strlen (suffix))
vty_out (vty, "%s", suffix);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,266
|
aspath_private_as_check (struct aspath *aspath)
{
struct assegment *seg;
if ( !(aspath && aspath->segments) )
return 0;
seg = aspath->segments;
while (seg)
{
int i;
for (i = 0; i < seg->length; i++)
{
if (!BGP_AS_IS_PRIVATE(seg->as[i]))
return 0;
}
seg = seg->next;
}
return 1;
}
|
DoS
| 0
|
aspath_private_as_check (struct aspath *aspath)
{
struct assegment *seg;
if ( !(aspath && aspath->segments) )
return 0;
seg = aspath->segments;
while (seg)
{
int i;
for (i = 0; i < seg->length; i++)
{
if (!BGP_AS_IS_PRIVATE(seg->as[i]))
return 0;
}
seg = seg->next;
}
return 1;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,267
|
aspath_reconcile_as4 ( struct aspath *aspath, struct aspath *as4path)
{
struct assegment *seg, *newseg, *prevseg = NULL;
struct aspath *newpath = NULL, *mergedpath;
int hops, cpasns = 0;
if (!aspath)
return NULL;
seg = aspath->segments;
/* CONFEDs should get reconciled too.. */
hops = (aspath_count_hops (aspath) + aspath_count_confeds (aspath))
- aspath_count_hops (as4path);
if (hops < 0)
{
if (BGP_DEBUG (as4, AS4))
zlog_warn ("[AS4] Fewer hops in AS_PATH than NEW_AS_PATH");
/* Something's gone wrong. The RFC says we should now ignore AS4_PATH,
* which is daft behaviour - it contains vital loop-detection
* information which must have been removed from AS_PATH.
*/
hops = aspath_count_hops (aspath);
}
if (!hops)
return aspath_dup (as4path);
if ( BGP_DEBUG(as4, AS4))
zlog_debug("[AS4] got AS_PATH %s and AS4_PATH %s synthesizing now",
aspath->str, as4path->str);
while (seg && hops > 0)
{
switch (seg->type)
{
case AS_SET:
case AS_CONFED_SET:
hops--;
cpasns = seg->length;
break;
case AS_CONFED_SEQUENCE:
/* Should never split a confed-sequence, if hop-count
* suggests we must then something's gone wrong somewhere.
*
* Most important goal is to preserve AS_PATHs prime function
* as loop-detector, so we fudge the numbers so that the entire
* confed-sequence is merged in.
*/
if (hops < seg->length)
{
if (BGP_DEBUG (as4, AS4))
zlog_debug ("[AS4] AS4PATHmangle: AS_CONFED_SEQUENCE falls"
" across 2/4 ASN boundary somewhere, broken..");
hops = seg->length;
}
case AS_SEQUENCE:
cpasns = MIN(seg->length, hops);
hops -= seg->length;
}
assert (cpasns <= seg->length);
newseg = assegment_new (seg->type, 0);
newseg = assegment_append_asns (newseg, seg->as, cpasns);
if (!newpath)
{
newpath = aspath_new ();
newpath->segments = newseg;
}
else
prevseg->next = newseg;
prevseg = newseg;
seg = seg->next;
}
/* We may be able to join some segments here, and we must
* do this because... we want normalised aspaths in out hash
* and we do not want to stumble in aspath_put.
*/
mergedpath = aspath_merge (newpath, aspath_dup(as4path));
aspath_free (newpath);
mergedpath->segments = assegment_normalise (mergedpath->segments);
aspath_str_update (mergedpath);
if ( BGP_DEBUG(as4, AS4))
zlog_debug ("[AS4] result of synthesizing is %s",
mergedpath->str);
return mergedpath;
}
|
DoS
| 0
|
aspath_reconcile_as4 ( struct aspath *aspath, struct aspath *as4path)
{
struct assegment *seg, *newseg, *prevseg = NULL;
struct aspath *newpath = NULL, *mergedpath;
int hops, cpasns = 0;
if (!aspath)
return NULL;
seg = aspath->segments;
/* CONFEDs should get reconciled too.. */
hops = (aspath_count_hops (aspath) + aspath_count_confeds (aspath))
- aspath_count_hops (as4path);
if (hops < 0)
{
if (BGP_DEBUG (as4, AS4))
zlog_warn ("[AS4] Fewer hops in AS_PATH than NEW_AS_PATH");
/* Something's gone wrong. The RFC says we should now ignore AS4_PATH,
* which is daft behaviour - it contains vital loop-detection
* information which must have been removed from AS_PATH.
*/
hops = aspath_count_hops (aspath);
}
if (!hops)
return aspath_dup (as4path);
if ( BGP_DEBUG(as4, AS4))
zlog_debug("[AS4] got AS_PATH %s and AS4_PATH %s synthesizing now",
aspath->str, as4path->str);
while (seg && hops > 0)
{
switch (seg->type)
{
case AS_SET:
case AS_CONFED_SET:
hops--;
cpasns = seg->length;
break;
case AS_CONFED_SEQUENCE:
/* Should never split a confed-sequence, if hop-count
* suggests we must then something's gone wrong somewhere.
*
* Most important goal is to preserve AS_PATHs prime function
* as loop-detector, so we fudge the numbers so that the entire
* confed-sequence is merged in.
*/
if (hops < seg->length)
{
if (BGP_DEBUG (as4, AS4))
zlog_debug ("[AS4] AS4PATHmangle: AS_CONFED_SEQUENCE falls"
" across 2/4 ASN boundary somewhere, broken..");
hops = seg->length;
}
case AS_SEQUENCE:
cpasns = MIN(seg->length, hops);
hops -= seg->length;
}
assert (cpasns <= seg->length);
newseg = assegment_new (seg->type, 0);
newseg = assegment_append_asns (newseg, seg->as, cpasns);
if (!newpath)
{
newpath = aspath_new ();
newpath->segments = newseg;
}
else
prevseg->next = newseg;
prevseg = newseg;
seg = seg->next;
}
/* We may be able to join some segments here, and we must
* do this because... we want normalised aspaths in out hash
* and we do not want to stumble in aspath_put.
*/
mergedpath = aspath_merge (newpath, aspath_dup(as4path));
aspath_free (newpath);
mergedpath->segments = assegment_normalise (mergedpath->segments);
aspath_str_update (mergedpath);
if ( BGP_DEBUG(as4, AS4))
zlog_debug ("[AS4] result of synthesizing is %s",
mergedpath->str);
return mergedpath;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,268
|
aspath_segment_add (struct aspath *as, int type)
{
struct assegment *seg = as->segments;
struct assegment *new = assegment_new (type, 0);
if (seg)
{
while (seg->next)
seg = seg->next;
seg->next = new;
}
else
as->segments = new;
}
|
DoS
| 0
|
aspath_segment_add (struct aspath *as, int type)
{
struct assegment *seg = as->segments;
struct assegment *new = assegment_new (type, 0);
if (seg)
{
while (seg->next)
seg = seg->next;
seg->next = new;
}
else
as->segments = new;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,269
|
aspath_str_update (struct aspath *as)
{
if (as->str)
XFREE (MTYPE_AS_STR, as->str);
aspath_make_str_count (as);
}
|
DoS
| 0
|
aspath_str_update (struct aspath *as)
{
if (as->str)
XFREE (MTYPE_AS_STR, as->str);
aspath_make_str_count (as);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,270
|
aspath_unintern (struct aspath **aspath)
{
struct aspath *ret;
struct aspath *asp = *aspath;
if (asp->refcnt)
asp->refcnt--;
if (asp->refcnt == 0)
{
/* This aspath must exist in aspath hash table. */
ret = hash_release (ashash, asp);
assert (ret != NULL);
aspath_free (asp);
*aspath = NULL;
}
}
|
DoS
| 0
|
aspath_unintern (struct aspath **aspath)
{
struct aspath *ret;
struct aspath *asp = *aspath;
if (asp->refcnt)
asp->refcnt--;
if (asp->refcnt == 0)
{
/* This aspath must exist in aspath hash table. */
ret = hash_release (ashash, asp);
assert (ret != NULL);
aspath_free (asp);
*aspath = NULL;
}
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,271
|
assegment_append_asns (struct assegment *seg, as_t *asnos, int num)
{
as_t *newas;
newas = XREALLOC (MTYPE_AS_SEG_DATA, seg->as,
ASSEGMENT_DATA_SIZE (seg->length + num, 1));
if (newas)
{
seg->as = newas;
memcpy (seg->as + seg->length, asnos, ASSEGMENT_DATA_SIZE(num, 1));
seg->length += num;
return seg;
}
assegment_free_all (seg);
return NULL;
}
|
DoS
| 0
|
assegment_append_asns (struct assegment *seg, as_t *asnos, int num)
{
as_t *newas;
newas = XREALLOC (MTYPE_AS_SEG_DATA, seg->as,
ASSEGMENT_DATA_SIZE (seg->length + num, 1));
if (newas)
{
seg->as = newas;
memcpy (seg->as + seg->length, asnos, ASSEGMENT_DATA_SIZE(num, 1));
seg->length += num;
return seg;
}
assegment_free_all (seg);
return NULL;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,272
|
assegment_count_asns (struct assegment *seg, int from)
{
int count = 0;
while (seg)
{
if (!from)
count += seg->length;
else
{
count += (seg->length - from);
from = 0;
}
seg = seg->next;
}
return count;
}
|
DoS
| 0
|
assegment_count_asns (struct assegment *seg, int from)
{
int count = 0;
while (seg)
{
if (!from)
count += seg->length;
else
{
count += (seg->length - from);
from = 0;
}
seg = seg->next;
}
return count;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,273
|
assegment_data_new (int num)
{
return (XMALLOC (MTYPE_AS_SEG_DATA, ASSEGMENT_DATA_SIZE (num, 1)));
}
|
DoS
| 0
|
assegment_data_new (int num)
{
return (XMALLOC (MTYPE_AS_SEG_DATA, ASSEGMENT_DATA_SIZE (num, 1)));
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,274
|
assegment_data_put (struct stream *s, as_t *as, int num, int use32bit)
{
int i;
assert (num <= AS_SEGMENT_MAX);
for (i = 0; i < num; i++)
if ( use32bit )
stream_putl (s, as[i]);
else
{
if ( as[i] <= BGP_AS_MAX )
stream_putw(s, as[i]);
else
stream_putw(s, BGP_AS_TRANS);
}
}
|
DoS
| 0
|
assegment_data_put (struct stream *s, as_t *as, int num, int use32bit)
{
int i;
assert (num <= AS_SEGMENT_MAX);
for (i = 0; i < num; i++)
if ( use32bit )
stream_putl (s, as[i]);
else
{
if ( as[i] <= BGP_AS_MAX )
stream_putw(s, as[i]);
else
stream_putw(s, BGP_AS_TRANS);
}
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,275
|
assegment_dup (struct assegment *seg)
{
struct assegment *new;
new = assegment_new (seg->type, seg->length);
memcpy (new->as, seg->as, ASSEGMENT_DATA_SIZE (new->length, 1) );
return new;
}
|
DoS
| 0
|
assegment_dup (struct assegment *seg)
{
struct assegment *new;
new = assegment_new (seg->type, seg->length);
memcpy (new->as, seg->as, ASSEGMENT_DATA_SIZE (new->length, 1) );
return new;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,276
|
assegment_dup_all (struct assegment *seg)
{
struct assegment *new = NULL;
struct assegment *head = NULL;
while (seg)
{
if (head)
{
new->next = assegment_dup (seg);
new = new->next;
}
else
head = new = assegment_dup (seg);
seg = seg->next;
}
return head;
}
|
DoS
| 0
|
assegment_dup_all (struct assegment *seg)
{
struct assegment *new = NULL;
struct assegment *head = NULL;
while (seg)
{
if (head)
{
new->next = assegment_dup (seg);
new = new->next;
}
else
head = new = assegment_dup (seg);
seg = seg->next;
}
return head;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,277
|
assegment_free_all (struct assegment *seg)
{
struct assegment *prev;
while (seg)
{
prev = seg;
seg = seg->next;
assegment_free (prev);
}
}
|
DoS
| 0
|
assegment_free_all (struct assegment *seg)
{
struct assegment *prev;
while (seg)
{
prev = seg;
seg = seg->next;
assegment_free (prev);
}
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,278
|
assegment_header_put (struct stream *s, u_char type, int length)
{
size_t lenp;
assert (length <= AS_SEGMENT_MAX);
stream_putc (s, type);
lenp = stream_get_endp (s);
stream_putc (s, length);
return lenp;
}
|
DoS
| 0
|
assegment_header_put (struct stream *s, u_char type, int length)
{
size_t lenp;
assert (length <= AS_SEGMENT_MAX);
stream_putc (s, type);
lenp = stream_get_endp (s);
stream_putc (s, length);
return lenp;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,279
|
assegments_parse (struct stream *s, size_t length,
struct assegment **result, int use32bit)
{
struct assegment_header segh;
struct assegment *seg, *prev = NULL, *head = NULL;
size_t bytes = 0;
/* empty aspath (ie iBGP or somesuch) */
if (length == 0)
return 0;
if (BGP_DEBUG (as4, AS4_SEGMENT))
zlog_debug ("[AS4SEG] Parse aspath segment: got total byte length %lu",
(unsigned long) length);
/* basic checks */
if ((STREAM_READABLE(s) < length)
|| (STREAM_READABLE(s) < AS_HEADER_SIZE)
|| (length % AS16_VALUE_SIZE ))
return -1;
while (bytes < length)
{
int i;
size_t seg_size;
if ((length - bytes) <= AS_HEADER_SIZE)
{
if (head)
assegment_free_all (head);
return -1;
}
/* softly softly, get the header first on its own */
segh.type = stream_getc (s);
segh.length = stream_getc (s);
seg_size = ASSEGMENT_SIZE(segh.length, use32bit);
if (BGP_DEBUG (as4, AS4_SEGMENT))
zlog_debug ("[AS4SEG] Parse aspath segment: got type %d, length %d",
segh.type, segh.length);
/* check it.. */
if ( ((bytes + seg_size) > length)
/* 1771bis 4.3b: seg length contains one or more */
|| (segh.length == 0)
/* Paranoia in case someone changes type of segment length.
* Shift both values by 0x10 to make the comparison operate
* on more, than 8 bits (otherwise it's a warning, bug #564).
*/
|| ((sizeof segh.length > 1)
&& (0x10 + segh.length > 0x10 + AS_SEGMENT_MAX)))
{
if (head)
assegment_free_all (head);
return -1;
}
switch (segh.type)
{
case AS_SEQUENCE:
case AS_SET:
case AS_CONFED_SEQUENCE:
case AS_CONFED_SET:
break;
default:
if (head)
assegment_free_all (head);
return -1;
}
/* now its safe to trust lengths */
seg = assegment_new (segh.type, segh.length);
if (head)
prev->next = seg;
else /* it's the first segment */
head = prev = seg;
for (i = 0; i < segh.length; i++)
seg->as[i] = (use32bit) ? stream_getl (s) : stream_getw (s);
bytes += seg_size;
if (BGP_DEBUG (as4, AS4_SEGMENT))
zlog_debug ("[AS4SEG] Parse aspath segment: Bytes now: %lu",
(unsigned long) bytes);
prev = seg;
}
*result = assegment_normalise (head);
return 0;
}
|
DoS
| 0
|
assegments_parse (struct stream *s, size_t length,
struct assegment **result, int use32bit)
{
struct assegment_header segh;
struct assegment *seg, *prev = NULL, *head = NULL;
size_t bytes = 0;
/* empty aspath (ie iBGP or somesuch) */
if (length == 0)
return 0;
if (BGP_DEBUG (as4, AS4_SEGMENT))
zlog_debug ("[AS4SEG] Parse aspath segment: got total byte length %lu",
(unsigned long) length);
/* basic checks */
if ((STREAM_READABLE(s) < length)
|| (STREAM_READABLE(s) < AS_HEADER_SIZE)
|| (length % AS16_VALUE_SIZE ))
return -1;
while (bytes < length)
{
int i;
size_t seg_size;
if ((length - bytes) <= AS_HEADER_SIZE)
{
if (head)
assegment_free_all (head);
return -1;
}
/* softly softly, get the header first on its own */
segh.type = stream_getc (s);
segh.length = stream_getc (s);
seg_size = ASSEGMENT_SIZE(segh.length, use32bit);
if (BGP_DEBUG (as4, AS4_SEGMENT))
zlog_debug ("[AS4SEG] Parse aspath segment: got type %d, length %d",
segh.type, segh.length);
/* check it.. */
if ( ((bytes + seg_size) > length)
/* 1771bis 4.3b: seg length contains one or more */
|| (segh.length == 0)
/* Paranoia in case someone changes type of segment length.
* Shift both values by 0x10 to make the comparison operate
* on more, than 8 bits (otherwise it's a warning, bug #564).
*/
|| ((sizeof segh.length > 1)
&& (0x10 + segh.length > 0x10 + AS_SEGMENT_MAX)))
{
if (head)
assegment_free_all (head);
return -1;
}
switch (segh.type)
{
case AS_SEQUENCE:
case AS_SET:
case AS_CONFED_SEQUENCE:
case AS_CONFED_SET:
break;
default:
if (head)
assegment_free_all (head);
return -1;
}
/* now its safe to trust lengths */
seg = assegment_new (segh.type, segh.length);
if (head)
prev->next = seg;
else /* it's the first segment */
head = prev = seg;
for (i = 0; i < segh.length; i++)
seg->as[i] = (use32bit) ? stream_getl (s) : stream_getw (s);
bytes += seg_size;
if (BGP_DEBUG (as4, AS4_SEGMENT))
zlog_debug ("[AS4SEG] Parse aspath segment: Bytes now: %lu",
(unsigned long) bytes);
prev = seg;
}
*result = assegment_normalise (head);
return 0;
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,280
|
int_cmp (const void *p1, const void *p2)
{
const as_t *as1 = p1;
const as_t *as2 = p2;
return (*as1 == *as2)
? 0 : ( (*as1 > *as2) ? 1 : -1);
}
|
DoS
| 0
|
int_cmp (const void *p1, const void *p2)
{
const as_t *as1 = p1;
const as_t *as2 = p2;
return (*as1 == *as2)
? 0 : ( (*as1 > *as2) ? 1 : -1);
}
|
@@ -903,7 +903,7 @@ aspath_put (struct stream *s, struct aspath *as, int use32bit )
assegment_header_put (s, seg->type, AS_SEGMENT_MAX);
assegment_data_put (s, seg->as, AS_SEGMENT_MAX, use32bit);
written += AS_SEGMENT_MAX;
- bytes += ASSEGMENT_SIZE (written, use32bit);
+ bytes += ASSEGMENT_SIZE (AS_SEGMENT_MAX, use32bit);
}
/* write the final segment, probably is also the first */
|
CWE-20
| null | null |
1,281
|
int canonical_checksum(int csum_type)
{
return csum_type >= CSUM_MD4 ? 1 : 0;
}
|
Bypass
| 0
|
int canonical_checksum(int csum_type)
{
return csum_type >= CSUM_MD4 ? 1 : 0;
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,282
|
int csum_len_for_type(int cst)
{
switch (cst) {
case CSUM_NONE:
return 1;
case CSUM_MD4_ARCHAIC:
return 2;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
return MD4_DIGEST_LEN;
case CSUM_MD5:
return MD5_DIGEST_LEN;
}
return 0;
}
|
Bypass
| 0
|
int csum_len_for_type(int cst)
{
switch (cst) {
case CSUM_NONE:
return 1;
case CSUM_MD4_ARCHAIC:
return 2;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
return MD4_DIGEST_LEN;
case CSUM_MD5:
return MD5_DIGEST_LEN;
}
return 0;
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,283
|
void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
{
struct map_struct *buf;
OFF_T i, len = st_p->st_size;
md_context m;
int32 remainder;
int fd;
memset(sum, 0, MAX_DIGEST_LEN);
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1)
return;
buf = map_file(fd, len, MAX_MAP_SIZE, CSUM_CHUNK);
switch (checksum_type) {
case CSUM_MD5:
md5_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
md5_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
remainder = (int32)(len - i);
if (remainder > 0)
md5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
md5_result(&m, (uchar *)sum);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC:
mdfour_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
/* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes. */
remainder = (int32)(len - i);
if (remainder > 0 || checksum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);
break;
default:
rprintf(FERROR, "invalid checksum-choice for the --checksum option (%d)\n", checksum_type);
exit_cleanup(RERR_UNSUPPORTED);
}
close(fd);
unmap_file(buf);
}
|
Bypass
| 0
|
void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
{
struct map_struct *buf;
OFF_T i, len = st_p->st_size;
md_context m;
int32 remainder;
int fd;
memset(sum, 0, MAX_DIGEST_LEN);
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1)
return;
buf = map_file(fd, len, MAX_MAP_SIZE, CSUM_CHUNK);
switch (checksum_type) {
case CSUM_MD5:
md5_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
md5_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
remainder = (int32)(len - i);
if (remainder > 0)
md5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
md5_result(&m, (uchar *)sum);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC:
mdfour_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
/* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes. */
remainder = (int32)(len - i);
if (remainder > 0 || checksum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);
break;
default:
rprintf(FERROR, "invalid checksum-choice for the --checksum option (%d)\n", checksum_type);
exit_cleanup(RERR_UNSUPPORTED);
}
close(fd);
unmap_file(buf);
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,284
|
uint32 get_checksum1(char *buf1, int32 len)
{
int32 i;
uint32 s1, s2;
schar *buf = (schar *)buf1;
s1 = s2 = 0;
for (i = 0; i < (len-4); i+=4) {
s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] +
10*CHAR_OFFSET;
s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET);
}
for (; i < len; i++) {
s1 += (buf[i]+CHAR_OFFSET); s2 += s1;
}
return (s1 & 0xffff) + (s2 << 16);
}
|
Bypass
| 0
|
uint32 get_checksum1(char *buf1, int32 len)
{
int32 i;
uint32 s1, s2;
schar *buf = (schar *)buf1;
s1 = s2 = 0;
for (i = 0; i < (len-4); i+=4) {
s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] +
10*CHAR_OFFSET;
s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET);
}
for (; i < len; i++) {
s1 += (buf[i]+CHAR_OFFSET); s2 += s1;
}
return (s1 & 0xffff) + (s2 << 16);
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,285
|
void get_checksum2(char *buf, int32 len, char *sum)
{
md_context m;
switch (xfersum_type) {
case CSUM_MD5: {
uchar seedbuf[4];
md5_begin(&m);
if (proper_seed_order) {
if (checksum_seed) {
SIVALu(seedbuf, 0, checksum_seed);
md5_update(&m, seedbuf, 4);
}
md5_update(&m, (uchar *)buf, len);
} else {
md5_update(&m, (uchar *)buf, len);
if (checksum_seed) {
SIVALu(seedbuf, 0, checksum_seed);
md5_update(&m, seedbuf, 4);
}
}
md5_result(&m, (uchar *)sum);
break;
}
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC: {
int32 i;
static char *buf1;
static int32 len1;
mdfour_begin(&m);
if (len > len1) {
if (buf1)
free(buf1);
buf1 = new_array(char, len+4);
len1 = len;
if (!buf1)
out_of_memory("get_checksum2");
}
memcpy(buf1, buf, len);
if (checksum_seed) {
SIVAL(buf1,len,checksum_seed);
len += 4;
}
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK)
mdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK);
/*
* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes.
*/
if (len - i > 0 || xfersum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)(buf1+i), len-i);
mdfour_result(&m, (uchar *)sum);
break;
}
}
}
|
Bypass
| 0
|
void get_checksum2(char *buf, int32 len, char *sum)
{
md_context m;
switch (xfersum_type) {
case CSUM_MD5: {
uchar seedbuf[4];
md5_begin(&m);
if (proper_seed_order) {
if (checksum_seed) {
SIVALu(seedbuf, 0, checksum_seed);
md5_update(&m, seedbuf, 4);
}
md5_update(&m, (uchar *)buf, len);
} else {
md5_update(&m, (uchar *)buf, len);
if (checksum_seed) {
SIVALu(seedbuf, 0, checksum_seed);
md5_update(&m, seedbuf, 4);
}
}
md5_result(&m, (uchar *)sum);
break;
}
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC: {
int32 i;
static char *buf1;
static int32 len1;
mdfour_begin(&m);
if (len > len1) {
if (buf1)
free(buf1);
buf1 = new_array(char, len+4);
len1 = len;
if (!buf1)
out_of_memory("get_checksum2");
}
memcpy(buf1, buf, len);
if (checksum_seed) {
SIVAL(buf1,len,checksum_seed);
len += 4;
}
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK)
mdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK);
/*
* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes.
*/
if (len - i > 0 || xfersum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)(buf1+i), len-i);
mdfour_result(&m, (uchar *)sum);
break;
}
}
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,286
|
int parse_checksum_choice(void)
{
char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
if (cp) {
xfersum_type = parse_csum_name(checksum_choice, cp - checksum_choice);
checksum_type = parse_csum_name(cp+1, -1);
} else
xfersum_type = checksum_type = parse_csum_name(checksum_choice, -1);
return xfersum_type == CSUM_NONE;
}
|
Bypass
| 0
|
int parse_checksum_choice(void)
{
char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
if (cp) {
xfersum_type = parse_csum_name(checksum_choice, cp - checksum_choice);
checksum_type = parse_csum_name(cp+1, -1);
} else
xfersum_type = checksum_type = parse_csum_name(checksum_choice, -1);
return xfersum_type == CSUM_NONE;
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,287
|
int parse_csum_name(const char *name, int len)
{
if (len < 0 && name)
len = strlen(name);
if (!name || (len == 4 && strncasecmp(name, "auto", 4) == 0)) {
if (protocol_version >= 30)
return CSUM_MD5;
if (protocol_version >= 27)
return CSUM_MD4_OLD;
if (protocol_version >= 21)
return CSUM_MD4_BUSTED;
return CSUM_MD4_ARCHAIC;
}
if (len == 3 && strncasecmp(name, "md4", 3) == 0)
return CSUM_MD4;
if (len == 3 && strncasecmp(name, "md5", 3) == 0)
return CSUM_MD5;
if (len == 4 && strncasecmp(name, "none", 4) == 0)
return CSUM_NONE;
rprintf(FERROR, "unknown checksum name: %s\n", name);
exit_cleanup(RERR_UNSUPPORTED);
}
|
Bypass
| 0
|
int parse_csum_name(const char *name, int len)
{
if (len < 0 && name)
len = strlen(name);
if (!name || (len == 4 && strncasecmp(name, "auto", 4) == 0)) {
if (protocol_version >= 30)
return CSUM_MD5;
if (protocol_version >= 27)
return CSUM_MD4_OLD;
if (protocol_version >= 21)
return CSUM_MD4_BUSTED;
return CSUM_MD4_ARCHAIC;
}
if (len == 3 && strncasecmp(name, "md4", 3) == 0)
return CSUM_MD4;
if (len == 3 && strncasecmp(name, "md5", 3) == 0)
return CSUM_MD5;
if (len == 4 && strncasecmp(name, "none", 4) == 0)
return CSUM_NONE;
rprintf(FERROR, "unknown checksum name: %s\n", name);
exit_cleanup(RERR_UNSUPPORTED);
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,288
|
void sum_init(int csum_type, int seed)
{
char s[4];
if (csum_type < 0)
csum_type = parse_csum_name(NULL, 0);
cursum_type = csum_type;
switch (csum_type) {
case CSUM_MD5:
md5_begin(&md);
break;
case CSUM_MD4:
mdfour_begin(&md);
sumresidue = 0;
break;
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC:
mdfour_begin(&md);
sumresidue = 0;
SIVAL(s, 0, seed);
sum_update(s, 4);
break;
case CSUM_NONE:
break;
}
}
|
Bypass
| 0
|
void sum_init(int csum_type, int seed)
{
char s[4];
if (csum_type < 0)
csum_type = parse_csum_name(NULL, 0);
cursum_type = csum_type;
switch (csum_type) {
case CSUM_MD5:
md5_begin(&md);
break;
case CSUM_MD4:
mdfour_begin(&md);
sumresidue = 0;
break;
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
case CSUM_MD4_ARCHAIC:
mdfour_begin(&md);
sumresidue = 0;
SIVAL(s, 0, seed);
sum_update(s, 4);
break;
case CSUM_NONE:
break;
}
}
|
@@ -295,6 +295,7 @@ void sum_update(const char *p, int32 len)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
|
CWE-354
| null | null |
1,289
|
void auth_client(int fd, const char *user, const char *challenge)
{
const char *pass;
char pass2[MAX_DIGEST_LEN*2];
if (!user || !*user)
user = "nobody";
if (!(pass = getpassf(password_file))
&& !(pass = getenv("RSYNC_PASSWORD"))) {
/* XXX: cyeoh says that getpass is deprecated, because
* it may return a truncated password on some systems,
* and it is not in the LSB.
*
* Andrew Klein says that getpassphrase() is present
* on Solaris and reads up to 256 characters.
*
* OpenBSD has a readpassphrase() that might be more suitable.
*/
pass = getpass("Password: ");
}
if (!pass)
pass = "";
generate_hash(pass, challenge, pass2);
io_printf(fd, "%s %s\n", user, pass2);
}
|
Bypass
| 0
|
void auth_client(int fd, const char *user, const char *challenge)
{
const char *pass;
char pass2[MAX_DIGEST_LEN*2];
if (!user || !*user)
user = "nobody";
if (!(pass = getpassf(password_file))
&& !(pass = getenv("RSYNC_PASSWORD"))) {
/* XXX: cyeoh says that getpass is deprecated, because
* it may return a truncated password on some systems,
* and it is not in the LSB.
*
* Andrew Klein says that getpassphrase() is present
* on Solaris and reads up to 256 characters.
*
* OpenBSD has a readpassphrase() that might be more suitable.
*/
pass = getpass("Password: ");
}
if (!pass)
pass = "";
generate_hash(pass, challenge, pass2);
io_printf(fd, "%s %s\n", user, pass2);
}
|
@@ -22,6 +22,7 @@
#include "itypes.h"
extern int read_only;
+extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -237,6 +238,11 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";
+ if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
+ rprintf(FERROR, "ERROR: protocol version is too old!\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
gen_challenge(addr, challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
|
CWE-354
| null | null |
1,290
|
void base64_encode(const char *buf, int len, char *out, int pad)
{
char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int bit_offset, byte_offset, idx, i;
const uchar *d = (const uchar *)buf;
int bytes = (len*8 + 5)/6;
for (i = 0; i < bytes; i++) {
byte_offset = (i*6)/8;
bit_offset = (i*6)%8;
if (bit_offset < 3) {
idx = (d[byte_offset] >> (2-bit_offset)) & 0x3F;
} else {
idx = (d[byte_offset] << (bit_offset-2)) & 0x3F;
if (byte_offset+1 < len) {
idx |= (d[byte_offset+1] >> (8-(bit_offset-2)));
}
}
out[i] = b64[idx];
}
while (pad && (i % 4))
out[i++] = '=';
out[i] = '\0';
}
|
Bypass
| 0
|
void base64_encode(const char *buf, int len, char *out, int pad)
{
char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int bit_offset, byte_offset, idx, i;
const uchar *d = (const uchar *)buf;
int bytes = (len*8 + 5)/6;
for (i = 0; i < bytes; i++) {
byte_offset = (i*6)/8;
bit_offset = (i*6)%8;
if (bit_offset < 3) {
idx = (d[byte_offset] >> (2-bit_offset)) & 0x3F;
} else {
idx = (d[byte_offset] << (bit_offset-2)) & 0x3F;
if (byte_offset+1 < len) {
idx |= (d[byte_offset+1] >> (8-(bit_offset-2)));
}
}
out[i] = b64[idx];
}
while (pad && (i % 4))
out[i++] = '=';
out[i] = '\0';
}
|
@@ -22,6 +22,7 @@
#include "itypes.h"
extern int read_only;
+extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -237,6 +238,11 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";
+ if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
+ rprintf(FERROR, "ERROR: protocol version is too old!\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
gen_challenge(addr, challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
|
CWE-354
| null | null |
1,291
|
static const char *check_secret(int module, const char *user, const char *group,
const char *challenge, const char *pass)
{
char line[1024];
char pass2[MAX_DIGEST_LEN*2];
const char *fname = lp_secrets_file(module);
STRUCT_STAT st;
int ok = 1;
int user_len = strlen(user);
int group_len = group ? strlen(group) : 0;
char *err;
FILE *fh;
if (!fname || !*fname || (fh = fopen(fname, "r")) == NULL)
return "no secrets file";
if (do_fstat(fileno(fh), &st) == -1) {
rsyserr(FLOG, errno, "fstat(%s)", fname);
ok = 0;
} else if (lp_strict_modes(module)) {
if ((st.st_mode & 06) != 0) {
rprintf(FLOG, "secrets file must not be other-accessible (see strict modes option)\n");
ok = 0;
} else if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FLOG, "secrets file must be owned by root when running as root (see strict modes)\n");
ok = 0;
}
}
if (!ok) {
fclose(fh);
return "ignoring secrets file";
}
if (*user == '#') {
/* Reject attempt to match a comment. */
fclose(fh);
return "invalid username";
}
/* Try to find a line that starts with the user (or @group) name and a ':'. */
err = "secret not found";
while ((user || group) && fgets(line, sizeof line, fh) != NULL) {
const char **ptr, *s = strtok(line, "\n\r");
int len;
if (!s)
continue;
if (*s == '@') {
ptr = &group;
len = group_len;
s++;
} else {
ptr = &user;
len = user_len;
}
if (!*ptr || strncmp(s, *ptr, len) != 0 || s[len] != ':')
continue;
generate_hash(s+len+1, challenge, pass2);
if (strcmp(pass, pass2) == 0) {
err = NULL;
break;
}
err = "password mismatch";
*ptr = NULL; /* Don't look for name again. */
}
fclose(fh);
memset(line, 0, sizeof line);
memset(pass2, 0, sizeof pass2);
return err;
}
|
Bypass
| 0
|
static const char *check_secret(int module, const char *user, const char *group,
const char *challenge, const char *pass)
{
char line[1024];
char pass2[MAX_DIGEST_LEN*2];
const char *fname = lp_secrets_file(module);
STRUCT_STAT st;
int ok = 1;
int user_len = strlen(user);
int group_len = group ? strlen(group) : 0;
char *err;
FILE *fh;
if (!fname || !*fname || (fh = fopen(fname, "r")) == NULL)
return "no secrets file";
if (do_fstat(fileno(fh), &st) == -1) {
rsyserr(FLOG, errno, "fstat(%s)", fname);
ok = 0;
} else if (lp_strict_modes(module)) {
if ((st.st_mode & 06) != 0) {
rprintf(FLOG, "secrets file must not be other-accessible (see strict modes option)\n");
ok = 0;
} else if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FLOG, "secrets file must be owned by root when running as root (see strict modes)\n");
ok = 0;
}
}
if (!ok) {
fclose(fh);
return "ignoring secrets file";
}
if (*user == '#') {
/* Reject attempt to match a comment. */
fclose(fh);
return "invalid username";
}
/* Try to find a line that starts with the user (or @group) name and a ':'. */
err = "secret not found";
while ((user || group) && fgets(line, sizeof line, fh) != NULL) {
const char **ptr, *s = strtok(line, "\n\r");
int len;
if (!s)
continue;
if (*s == '@') {
ptr = &group;
len = group_len;
s++;
} else {
ptr = &user;
len = user_len;
}
if (!*ptr || strncmp(s, *ptr, len) != 0 || s[len] != ':')
continue;
generate_hash(s+len+1, challenge, pass2);
if (strcmp(pass, pass2) == 0) {
err = NULL;
break;
}
err = "password mismatch";
*ptr = NULL; /* Don't look for name again. */
}
fclose(fh);
memset(line, 0, sizeof line);
memset(pass2, 0, sizeof pass2);
return err;
}
|
@@ -22,6 +22,7 @@
#include "itypes.h"
extern int read_only;
+extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -237,6 +238,11 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";
+ if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
+ rprintf(FERROR, "ERROR: protocol version is too old!\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
gen_challenge(addr, challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
|
CWE-354
| null | null |
1,292
|
static void gen_challenge(const char *addr, char *challenge)
{
char input[32];
char digest[MAX_DIGEST_LEN];
struct timeval tv;
int len;
memset(input, 0, sizeof input);
strlcpy(input, addr, 17);
sys_gettimeofday(&tv);
SIVAL(input, 16, tv.tv_sec);
SIVAL(input, 20, tv.tv_usec);
SIVAL(input, 24, getpid());
sum_init(-1, 0);
sum_update(input, sizeof input);
len = sum_end(digest);
base64_encode(digest, len, challenge, 0);
}
|
Bypass
| 0
|
static void gen_challenge(const char *addr, char *challenge)
{
char input[32];
char digest[MAX_DIGEST_LEN];
struct timeval tv;
int len;
memset(input, 0, sizeof input);
strlcpy(input, addr, 17);
sys_gettimeofday(&tv);
SIVAL(input, 16, tv.tv_sec);
SIVAL(input, 20, tv.tv_usec);
SIVAL(input, 24, getpid());
sum_init(-1, 0);
sum_update(input, sizeof input);
len = sum_end(digest);
base64_encode(digest, len, challenge, 0);
}
|
@@ -22,6 +22,7 @@
#include "itypes.h"
extern int read_only;
+extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -237,6 +238,11 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";
+ if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
+ rprintf(FERROR, "ERROR: protocol version is too old!\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
gen_challenge(addr, challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
|
CWE-354
| null | null |
1,293
|
static void generate_hash(const char *in, const char *challenge, char *out)
{
char buf[MAX_DIGEST_LEN];
int len;
sum_init(-1, 0);
sum_update(in, strlen(in));
sum_update(challenge, strlen(challenge));
len = sum_end(buf);
base64_encode(buf, len, out, 0);
}
|
Bypass
| 0
|
static void generate_hash(const char *in, const char *challenge, char *out)
{
char buf[MAX_DIGEST_LEN];
int len;
sum_init(-1, 0);
sum_update(in, strlen(in));
sum_update(challenge, strlen(challenge));
len = sum_end(buf);
base64_encode(buf, len, out, 0);
}
|
@@ -22,6 +22,7 @@
#include "itypes.h"
extern int read_only;
+extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -237,6 +238,11 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";
+ if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
+ rprintf(FERROR, "ERROR: protocol version is too old!\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
gen_challenge(addr, challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
|
CWE-354
| null | null |
1,294
|
static const char *getpassf(const char *filename)
{
STRUCT_STAT st;
char buffer[512], *p;
int n;
if (!filename)
return NULL;
if (strcmp(filename, "-") == 0) {
n = fgets(buffer, sizeof buffer, stdin) == NULL ? -1 : (int)strlen(buffer);
} else {
int fd;
if ((fd = open(filename,O_RDONLY)) < 0) {
rsyserr(FERROR, errno, "could not open password file %s", filename);
exit_cleanup(RERR_SYNTAX);
}
if (do_stat(filename, &st) == -1) {
rsyserr(FERROR, errno, "stat(%s)", filename);
exit_cleanup(RERR_SYNTAX);
}
if ((st.st_mode & 06) != 0) {
rprintf(FERROR, "ERROR: password file must not be other-accessible\n");
exit_cleanup(RERR_SYNTAX);
}
if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FERROR, "ERROR: password file must be owned by root when running as root\n");
exit_cleanup(RERR_SYNTAX);
}
n = read(fd, buffer, sizeof buffer - 1);
close(fd);
}
if (n > 0) {
buffer[n] = '\0';
if ((p = strtok(buffer, "\n\r")) != NULL)
return strdup(p);
}
rprintf(FERROR, "ERROR: failed to read a password from %s\n", filename);
exit_cleanup(RERR_SYNTAX);
}
|
Bypass
| 0
|
static const char *getpassf(const char *filename)
{
STRUCT_STAT st;
char buffer[512], *p;
int n;
if (!filename)
return NULL;
if (strcmp(filename, "-") == 0) {
n = fgets(buffer, sizeof buffer, stdin) == NULL ? -1 : (int)strlen(buffer);
} else {
int fd;
if ((fd = open(filename,O_RDONLY)) < 0) {
rsyserr(FERROR, errno, "could not open password file %s", filename);
exit_cleanup(RERR_SYNTAX);
}
if (do_stat(filename, &st) == -1) {
rsyserr(FERROR, errno, "stat(%s)", filename);
exit_cleanup(RERR_SYNTAX);
}
if ((st.st_mode & 06) != 0) {
rprintf(FERROR, "ERROR: password file must not be other-accessible\n");
exit_cleanup(RERR_SYNTAX);
}
if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FERROR, "ERROR: password file must be owned by root when running as root\n");
exit_cleanup(RERR_SYNTAX);
}
n = read(fd, buffer, sizeof buffer - 1);
close(fd);
}
if (n > 0) {
buffer[n] = '\0';
if ((p = strtok(buffer, "\n\r")) != NULL)
return strdup(p);
}
rprintf(FERROR, "ERROR: failed to read a password from %s\n", filename);
exit_cleanup(RERR_SYNTAX);
}
|
@@ -22,6 +22,7 @@
#include "itypes.h"
extern int read_only;
+extern int protocol_version;
extern char *password_file;
/***************************************************************************
@@ -237,6 +238,11 @@ char *auth_server(int f_in, int f_out, int module, const char *host,
if (!users || !*users)
return "";
+ if (protocol_version < 21) { /* Don't allow a weak checksum for the password. */
+ rprintf(FERROR, "ERROR: protocol version is too old!\n");
+ exit_cleanup(RERR_PROTOCOL);
+ }
+
gen_challenge(addr, challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
|
CWE-354
| null | null |
1,295
|
void sum_update(const char *p, int32 len)
{
switch (cursum_type) {
case CSUM_MD5:
md5_update(&md, (uchar *)p, len);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
break;
}
if (sumresidue) {
int32 i = CSUM_CHUNK - sumresidue;
memcpy(md.buffer + sumresidue, p, i);
mdfour_update(&md, (uchar *)md.buffer, CSUM_CHUNK);
len -= i;
p += i;
}
while (len >= CSUM_CHUNK) {
mdfour_update(&md, (uchar *)p, CSUM_CHUNK);
len -= CSUM_CHUNK;
p += CSUM_CHUNK;
}
sumresidue = len;
if (sumresidue)
memcpy(md.buffer, p, sumresidue);
break;
case CSUM_NONE:
break;
}
}
|
Bypass
| 0
|
void sum_update(const char *p, int32 len)
{
switch (cursum_type) {
case CSUM_MD5:
md5_update(&md, (uchar *)p, len);
break;
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
break;
}
if (sumresidue) {
int32 i = CSUM_CHUNK - sumresidue;
memcpy(md.buffer + sumresidue, p, i);
mdfour_update(&md, (uchar *)md.buffer, CSUM_CHUNK);
len -= i;
p += i;
}
while (len >= CSUM_CHUNK) {
mdfour_update(&md, (uchar *)p, CSUM_CHUNK);
len -= CSUM_CHUNK;
p += CSUM_CHUNK;
}
sumresidue = len;
if (sumresidue)
memcpy(md.buffer, p, sumresidue);
break;
case CSUM_NONE:
break;
}
}
|
@@ -27,7 +27,7 @@ extern int proper_seed_order;
extern char *checksum_choice;
#define CSUM_NONE 0
-#define CSUM_ARCHAIC 1
+#define CSUM_MD4_ARCHAIC 1
#define CSUM_MD4_BUSTED 2
#define CSUM_MD4_OLD 3
#define CSUM_MD4 4
@@ -60,7 +60,7 @@ int parse_csum_name(const char *name, int len)
return CSUM_MD4_OLD;
if (protocol_version >= 21)
return CSUM_MD4_BUSTED;
- return CSUM_ARCHAIC;
+ return CSUM_MD4_ARCHAIC;
}
if (len == 3 && strncasecmp(name, "md4", 3) == 0)
return CSUM_MD4;
@@ -78,7 +78,7 @@ int csum_len_for_type(int cst)
switch (cst) {
case CSUM_NONE:
return 1;
- case CSUM_ARCHAIC:
+ case CSUM_MD4_ARCHAIC:
return 2;
case CSUM_MD4:
case CSUM_MD4_OLD:
@@ -143,7 +143,8 @@ void get_checksum2(char *buf, int32 len, char *sum)
}
case CSUM_MD4:
case CSUM_MD4_OLD:
- case CSUM_MD4_BUSTED: {
+ case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC: {
int32 i;
static char *buf1;
static int32 len1;
@@ -174,7 +175,7 @@ void get_checksum2(char *buf, int32 len, char *sum)
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes.
*/
- if (len - i > 0 || xfersum_type != CSUM_MD4_BUSTED)
+ if (len - i > 0 || xfersum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)(buf1+i), len-i);
mdfour_result(&m, (uchar *)sum);
@@ -217,6 +218,7 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
case CSUM_MD4:
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
mdfour_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
@@ -229,7 +231,7 @@ void file_checksum(const char *fname, const STRUCT_STAT *st_p, char *sum)
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes. */
remainder = (int32)(len - i);
- if (remainder > 0 || checksum_type != CSUM_MD4_BUSTED)
+ if (remainder > 0 || checksum_type > CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);
@@ -265,6 +267,7 @@ void sum_init(int csum_type, int seed)
break;
case CSUM_MD4_OLD:
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
mdfour_begin(&md);
sumresidue = 0;
SIVAL(s, 0, seed);
@@ -321,6 +324,10 @@ void sum_update(const char *p, int32 len)
}
}
+/* NOTE: all the callers of sum_end() pass in a pointer to a buffer that is
+ * MAX_DIGEST_LEN in size, so even if the csum-len is shorter that that (i.e.
+ * CSUM_MD4_ARCHAIC), we don't have to worry about limiting the data we write
+ * into the "sum" buffer. */
int sum_end(char *sum)
{
switch (cursum_type) {
@@ -333,6 +340,7 @@ int sum_end(char *sum)
mdfour_result(&md, (uchar *)sum);
break;
case CSUM_MD4_BUSTED:
+ case CSUM_MD4_ARCHAIC:
if (sumresidue)
mdfour_update(&md, (uchar *)md.buffer, sumresidue);
mdfour_result(&md, (uchar *)sum);
|
CWE-354
| null | null |
1,296
|
static ENUM_PTRS_BEGIN(pattern1_instance_enum_ptrs) {
if (index < st_pattern1_template_max_ptrs) {
gs_ptr_type_t ptype =
ENUM_SUPER_ELT(gs_pattern1_instance_t, st_pattern1_template,
templat, 0);
if (ptype)
return ptype;
return ENUM_OBJ(NULL); /* don't stop early */
}
ENUM_PREFIX(st_pattern_instance, st_pattern1_template_max_ptrs);
} ENUM_PTRS_END
|
Exec Code
| 0
|
static ENUM_PTRS_BEGIN(pattern1_instance_enum_ptrs) {
if (index < st_pattern1_template_max_ptrs) {
gs_ptr_type_t ptype =
ENUM_SUPER_ELT(gs_pattern1_instance_t, st_pattern1_template,
templat, 0);
if (ptype)
return ptype;
return ENUM_OBJ(NULL); /* don't stop early */
}
ENUM_PREFIX(st_pattern_instance, st_pattern1_template_max_ptrs);
} ENUM_PTRS_END
|
@@ -50,7 +50,7 @@
/* GC descriptors */
private_st_pattern1_template();
-private_st_pattern1_instance();
+public_st_pattern1_instance();
/* GC procedures */
static ENUM_PTRS_BEGIN(pattern1_instance_enum_ptrs) {
|
CWE-704
| null | null |
1,297
|
static ENUM_PTRS_BEGIN(dc_binary_masked_enum_ptrs)
{
return ENUM_USING(st_dc_ht_binary, vptr, size, index - 2);
}
|
Exec Code
| 0
|
static ENUM_PTRS_BEGIN(dc_binary_masked_enum_ptrs)
{
return ENUM_USING(st_dc_ht_binary, vptr, size, index - 2);
}
|
@@ -50,7 +50,7 @@
/* GC descriptors */
private_st_pattern1_template();
-private_st_pattern1_instance();
+public_st_pattern1_instance();
/* GC procedures */
static ENUM_PTRS_BEGIN(pattern1_instance_enum_ptrs) {
|
CWE-704
| null | null |
1,298
|
ENUM_PTRS_WITH(dc_pattern_enum_ptrs, gx_device_color *cptr)
{
return ENUM_USING(st_dc_pure_masked, vptr, size, index - 1);
}
|
Exec Code
| 0
|
ENUM_PTRS_WITH(dc_pattern_enum_ptrs, gx_device_color *cptr)
{
return ENUM_USING(st_dc_pure_masked, vptr, size, index - 1);
}
|
@@ -50,7 +50,7 @@
/* GC descriptors */
private_st_pattern1_template();
-private_st_pattern1_instance();
+public_st_pattern1_instance();
/* GC procedures */
static ENUM_PTRS_BEGIN(pattern1_instance_enum_ptrs) {
|
CWE-704
| null | null |
1,299
|
static RELOC_PTRS_BEGIN(dc_binary_masked_reloc_ptrs)
{
RELOC_USING(st_dc_pure_masked, vptr, size);
RELOC_USING(st_dc_ht_binary, vptr, size);
}
|
Exec Code
| 0
|
static RELOC_PTRS_BEGIN(dc_binary_masked_reloc_ptrs)
{
RELOC_USING(st_dc_pure_masked, vptr, size);
RELOC_USING(st_dc_ht_binary, vptr, size);
}
|
@@ -50,7 +50,7 @@
/* GC descriptors */
private_st_pattern1_template();
-private_st_pattern1_instance();
+public_st_pattern1_instance();
/* GC procedures */
static ENUM_PTRS_BEGIN(pattern1_instance_enum_ptrs) {
|
CWE-704
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.