Fix wslua_filehandler_open() to work as wiretap open routines should.

They should return 1 on success, -1 on error, and 0 if there was no
error but the file isn't one of the type for the routine.  They must not
return any other value.  If they return -1, they must set *err.

Change-Id: I0f1e1675b4cc8f0214ad67a23de0e4ecb09cabea
Reviewed-on: https://code.wireshark.org/review/4221
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-09-20 15:51:10 -07:00
parent 8605bbfb64
commit 5e231d1d9c
1 changed files with 12 additions and 2 deletions

View File

@ -1653,7 +1653,7 @@ wslua_filehandler_sequential_close(wtap *wth);
* field in the "struct wtap" to the type of the file.
*/
static int
wslua_filehandler_open(wtap *wth, int *err _U_, gchar **err_info)
wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
{
FileHandler fh = (FileHandler)(wth->wslua_data);
int retval = 0;
@ -1708,10 +1708,20 @@ wslua_filehandler_open(wtap *wth, int *err _U_, gchar **err_info)
wth->file_type_subtype = fh->file_type;
}
else {
else if (retval == -1) {
/* open error - we *must* return an error code! */
*err = WTAP_ERR_CANT_OPEN;
}
else if (retval == 0) {
/* not our file type */
remove_wth_priv(L, wth);
}
else {
/* not a valid return type */
g_warning("FileHandler read_open routine returned %d", retval);
*err = WTAP_ERR_INTERNAL;
retval = -1;
}
lua_settop(L,0);
return retval;