Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoked undefined behavior in scan6.c #34

Closed
alvarezp opened this issue Nov 1, 2014 · 1 comment
Closed

Invoked undefined behavior in scan6.c #34

alvarezp opened this issue Nov 1, 2014 · 1 comment

Comments

@alvarezp
Copy link
Contributor

alvarezp commented Nov 1, 2014

Hello. GCC detected an invocation of undefined behavior in scan6.c. I think the error is caused because when j==16, memory accessed falls outside of an s6_addr array.

This is what I mean:

diff --git a/tools/scan6.c b/tools/scan6.c
index 49780d3..96781ca 100644
--- a/tools/scan6.c
+++ b/tools/scan6.c
@@ -3917,10 +3917,10 @@ int load_smart_entries(struct scan_list *scan, struct scan_list *smart){
                        case IID_PATTERN_BYTES:
                                (scan->target[scan->ntarget])->end= (scan->target[scan->ntarget])->start;

-                               for(j=8; j<=16; j++)
+                               for(j=8; j<16; j++)
                                        (scan->target[scan->ntarget])->end.s6addr[j]= ((scan->target[scan->ntarget])->start.s6addr[j])?0xff:0x00;

-                               for(j=8; j<=16; j++)
+                               for(j=8; j<16; j++)
                                        (scan->target[scan->ntarget])->start.s6addr[j]= 0x00;

                                (scan->target[scan->ntarget])->cur= (scan->target[scan->ntarget])->start;
@@ -3946,10 +3946,10 @@ int load_smart_entries(struct scan_list *scan, struct scan_list *smart){

                        default:
                                /* By default we scan for low-byte-addresses (same code as above) */
-                               for(j=8; j<=16; j++)
+                               for(j=8; j<16; j++)
                                        (scan->target[scan->ntarget])->start.s6addr[j]= 0x00;

-                               for(j=8; j<=16; j++)
+                               for(j=8; j<16; j++)
                                        (scan->target[scan->ntarget])->end.s6addr[j]= 0xff;

                                (scan->target[scan->ntarget])->cur= (scan->target[scan->ntarget])->start;
@fgont
Copy link
Owner

fgont commented Jun 29, 2015

I've applied this patch (you were right).

@fgont fgont closed this as completed Jun 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants