>Hello Guys,
>
>I received SIGSEGV in awk,
>looked around a bit
>found some issue,
>asking for help from AWK OWNER
>
>At,   awk.c:2626
>what if next_input_file() returns NULL, then the following code is gonna 
>get SIGSEGV for sure.
>
>
>} else {
>       if (!iF)
>               iF = next_input_file(); // if returns NULL
>       rsm = iF;
>}
>
>if (!rsm->F) {                         // then SIGSEGV here
>       setvar_i(intvar[ERRNO], errno);
>       setvar_i(res, -1);
>       break;
>}
>
>And there are other points to get SIGSEGV if I fix just the above.
>
>I am looking into it.
>
>
>Be :-),
>Deepak Jangid

I have made a patch for the SIGSEGV in awk, can somebody help me confirm it
if it's right way to go.

--- a/busybox/editors/awk.c       2009-06-05 17:45:40.000000000 +0530
+++ b/busybox/editors/awk.c    2011-09-06 07:23:45.000000000 +0530
@@ -1726,6 +1726,9 @@
        /* we're using our own buffer since we need access to accumulating
         * characters
         */
+
+       if(!rsm) return 0;
+
        fd = fileno(rsm->F);
        m = rsm->buffer;
        a = rsm->adv;
@@ -2408,7 +2411,7 @@
                                X.rsm = iF;
                        }
 
-                       if (!X.rsm->F) {
+                       if ( X.rsm && !X.rsm->F) {
                                setvar_i(intvar[ERRNO], errno);
                                setvar_i(res, -1);
                                break;


Happy Coding ........
Deepak Jangid

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to