After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 569061 - crash with write protected file
crash with write protected file
Status: RESOLVED FIXED
Product: gtranslator
Classification: Other
Component: general
HEAD
Other Linux
: Normal major
: 2.0
Assigned To: gtranslator-maint
gtranslator-maint
Depends on:
Blocks:
 
 
Reported: 2009-01-25 11:33 UTC by Florian Steinel
Modified: 2009-08-21 15:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtranslator-file-readonly (4.01 KB, patch)
2009-01-25 14:50 UTC, Florian Steinel
none Details | Review
gtranslator-file-readonly (2.89 KB, patch)
2009-02-01 12:39 UTC, Florian Steinel
none Details | Review
Before write the file checks if it is read only, in this case displays an error message. This can be a provisional fix of bug 569061 (2.07 KB, patch)
2009-08-18 16:29 UTC, fpuga
none Details | Review
Before save a file checks if it is read only, in this case displays an error message. (2.19 KB, patch)
2009-08-20 18:58 UTC, fpuga
none Details | Review

Description Florian Steinel 2009-01-25 11:33:22 UTC
crash while saving to a write proteced file:

Distribution: Gentoo Base System release 2.0.0
Gnome Release: 2.24.3 2009-01-24 (Gentoo)
BugBuddy Version: 2.24.2

System: Linux 2.6.28-gentoo #3 SMP Mon Jan 5 15:41:04 CET 2009 x86_64
X Vendor: The X.Org Foundation
X Vendor Release: 10599003
Selinux: No
Accessibility: Disabled
GTK+ Theme: Clearlooks
Icon Theme: gnome

Memory status: size: 214798336 vsize: 214798336 resident: 47321088 share: 12464128 rss: 47321088 rss_rlim: 18446744073709551615
CPU usage: start_time: 1232882814 rtime: 48 utime: 43 stime: 5 cutime:0 cstime: 0 timeout: 0 it_real_value: 0 frequency: 100

Backtrace was generated from '/usr/bin/gtranslator'

[?1034h[Thread debugging using libthread_db enabled]
[New Thread 0x7f47b6d8e6f0 (LWP 4122)]
0x00007f47b66b43b5 in __libc_waitpid (pid=4124, stat_loc=0x7fffbedb73d0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:32
	in ../sysdeps/unix/sysv/linux/waitpid.c

Thread 1 (Thread 0x7f47b6d8e6f0 (LWP 4122))

  • #0 __libc_waitpid
    at ../sysdeps/unix/sysv/linux/waitpid.c line 32
  • #1 IA__g_spawn_sync
    at gspawn.c line 382
  • #2 IA__g_spawn_command_line_sync
    at gspawn.c line 694
  • #3 bugbuddy_segv_handle
    from /usr/lib64/gtk-2.0/modules/libgnomebreakpad.so
  • #4 <signal handler called>
  • #5 _IO_fwrite
    at iofwrite.c line 43
  • #6 libgettextpo_message_print_comment
    at ostream.h line 88
  • #7 msgdomain_list_print_po
    at ../src/write-po.c line 1172
  • #8 libgettextpo_msgdomain_list_print
    at ../src/write-catalog.c line 308
  • #9 po_file_write_v2
    at gettext-po.c line 235
  • #10 gtranslator_po_save_file
    at po.c line 822
  • #11 gtranslator_save_current_file_dialog
    at actions-file.c line 382
  • #12 IA__g_closure_invoke
    at gclosure.c line 767
  • #13 signal_emit_unlocked_R
    at gsignal.c line 3244
  • #14 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #15 IA__g_signal_emit
    at gsignal.c line 3034
  • #16 _gtk_action_emit_activate
    at gtkaction.c line 885
  • #17 IA__g_closure_invoke
    at gclosure.c line 767
  • #18 signal_emit_unlocked_R
    at gsignal.c line 3244
  • #19 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #20 IA__g_signal_emit_by_name
    at gsignal.c line 3071
  • #21 IA__g_closure_invoke
    at gclosure.c line 767
  • #22 signal_emit_unlocked_R
    at gsignal.c line 3244
  • #23 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #24 IA__g_signal_emit
    at gsignal.c line 3034
  • #25 gtk_real_button_released
    at gtkbutton.c line 1491
  • #26 IA__g_closure_invoke
    at gclosure.c line 767
  • #27 signal_emit_unlocked_R
    at gsignal.c line 3174
  • #28 IA__g_signal_emit_valist
    at gsignal.c line 2977
  • #29 IA__g_signal_emit
    at gsignal.c line 3034
  • #30 gtk_button_button_release
    at gtkbutton.c line 1383
  • #31 _gtk_marshal_BOOLEAN__BOXED
    at gtkmarshalers.c line 84
  • #32 IA__g_closure_invoke
    at gclosure.c line 767
  • #33 signal_emit_unlocked_R
    at gsignal.c line 3282
  • #34 IA__g_signal_emit_valist
    at gsignal.c line 2987
  • #35 IA__g_signal_emit
    at gsignal.c line 3034
  • #36 gtk_widget_event_internal
    at gtkwidget.c line 4745
  • #37 IA__gtk_propagate_event
    at gtkmain.c line 2391
  • #38 IA__gtk_main_do_event
    at gtkmain.c line 1596
  • #39 gdk_event_dispatch
    at gdkevents-x11.c line 2365
  • #40 IA__g_main_context_dispatch
    at gmain.c line 1814
  • #41 g_main_context_iterate
    at gmain.c line 2448
  • #42 IA__g_main_loop_run
    at gmain.c line 2656
  • #43 IA__gtk_main
    at gtkmain.c line 1200
  • #44 main
    at main.c line 199

Comment 1 Florian Steinel 2009-01-25 14:50:27 UTC
Created attachment 127204 [details] [review]
gtranslator-file-readonly
Comment 2 Christian Kirbach 2009-01-26 19:54:34 UTC
Thanks for the patch.

I think we should convert the C++ sytle comments

  //"error querying file info for %s: %s", location, error->message;

to C style /*  */.

This is also copy & paste four times. Is it worth using a function four times here?
Comment 3 Florian Steinel 2009-01-26 21:32:45 UTC
I would like to readuce those test to one (in po.c) .
Then I tried to test for the readonly file in po.c but gtranslator crashed again.
Those GTR_PO_* error are not fatal?


Comment 4 Florian Steinel 2009-02-01 12:39:58 UTC
Created attachment 127693 [details] [review]
gtranslator-file-readonly

Fixed error in previous patch. 
- Only one readonly check
- Display fatal error
Comment 5 Christian Kirbach 2009-04-19 21:16:58 UTC
Hmm its odd the patch does not compile for me

po.c: In Funktion »gtranslator_po_save_file«:
po.c:789: Fehler: Anfrage nach Element »code« in etwas, was keine Struktur oder Variante ist
po.c:790: Warnung: format »%s« erwartet Typ »char *«, aber Argument 4 hat Typ »struct GFile *«
po.c:794: Fehler: Anfrage nach Element »message« in etwas, was keine Struktur oder Variante ist
po.c:794: Warnung: format »%s« erwartet Typ »char *«, aber Argument 4 hat Typ »struct GFile *«
make[4]: *** [po.lo] Fehler 1
Comment 6 fpuga 2009-08-18 16:27:40 UTC
I rewrite the patch provided by Florian and i think that works, but i think that can be improved.

Now same error is displayed when try to overwrite a read-only (ro) file, or when the current file is ro and we modified and try to save it.

Gedit makes it in a different way, when you open a file if it is ro "Save" button can't be clicked you must used "Save as". I think this is the more correct solution.
Comment 7 fpuga 2009-08-18 16:29:41 UTC
Created attachment 141094 [details] [review]
Before write the file checks if it is read only, in this case displays an error message. This can be a provisional fix of bug 569061
Comment 8 Ignacio Casal Quinteiro (nacho) 2009-08-18 21:16:18 UTC
Some things about your patch:

+static gboolean
+is_read_only (gchar *filename)

It should be const gchar *

+	location = g_file_new_for_path(filename);
here the coding style is wrong
+	info = g_file_query_info (location,
+				  G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
+				  G_FILE_QUERY_INFO_NONE,
+				  NULL,
+				  NULL);

it is missing the g_object_unref for location

 
+	if (is_read_only(filename))
+	  {
+	    g_set_error(error,
+			GTR_PO_ERROR,
+			GTR_PO_ERROR_READONLY,
+			_("The file %s is read-only, and can not be overwritten"),
+			filename);
+	    g_free (filename);
+	    return;
+	  }
+

here you are using a different coding style.
Comment 9 fpuga 2009-08-20 18:58:32 UTC
Created attachment 141275 [details] [review]
Before save a file checks if it is read only, in this case displays an error message.

I correct missing g_object_unref and correct the code style following gnu style as psanxiao recommended me.
Comment 10 Pablo Sanxiao 2009-08-21 15:08:19 UTC
The patch has been applied into master. It will be available in the next major software release. Thank you.