[gpm](no subject)
Kerry Scott McLeod
gt2921b@prism.gatech.edu
Thu, 13 Jun 2002 00:05:37 -0400 (EDT)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-1804928587-1023941137=:17221
Content-Type: TEXT/PLAIN; charset=US-ASCII
When Gpm_Connect is called with the paramater "flag" set to an
appropriate value (to denote the tty that the app in need of
gpm communications is running on), the full path to the tty
being specified is not constructed correctly, and thus the stat
function is unable to ascertain the uid of the tty owner. In short -
I have corrected this problem, and here is a simple patch that
I would really appreciate having commited to the gpm cvs tree - pending
approval. Also, I am now aware of the cvs's location. While the patch
was built using gpm-1.20.0, it does apply cleanly to the current cvs.
Next time I will use the cvs to make any further fixes.
Thanks,
-Scott
P.S. if I've violated any etiquette, or you didn't want me to attach
the patch and include it in the post.. any of these things.. please
politely inform me and I will do things correctly next time. I'm
new at this bussiness of commiting my fixes back to the maintainer.
diff -urN ./gpm-1.20.0.orig/src/liblow.c ./gpm-1.20.0/src/liblow.c
--- ./gpm-1.20.0.orig/src/liblow.c 2002-02-23 10:42:23.000000000 -0500
+++ ./gpm-1.20.0/src/liblow.c 2002-06-13 00:20:06.000000000 -0400
@@ -243,9 +243,25 @@
conn->vc=0; /* default handler */
if (flag > 0) { /* forced vc number */
conn->vc=flag;
- if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) != NULL)
+ if((tty = malloc(strlen(consolename)+Gpm_cnt_digits(flag))) == NULL)
gpm_report(GPM_PR_OOPS,GPM_MESS_NO_MEM);
- snprintf(tty,strlen(consolename)-1,"%s",consolename);
+ /*
+ * Modified on 06/12/2002
+ * by Kerry Scott McLeod (gt2921b@prism.gatech.edu)
+ *
+ * Relying on snprintf to truncate the string
+ * is a bad idea. Although a quick read through
+ * the glibc implementation shows that upon truncation,
+ * the last character to be written will be \0 and not
+ * a character from the source array, this feature is not
+ * documented - and thus it's most likely a bad idea to rely
+ * on it. I have replaced the following code with a memcpy.
+ *
+ * snprintf(tty,strlen(consolename)-1,"%s",consolename);
+ *
+ * (ex: /dev/tty0 becomes /dev/tty).
+ */
+ memcpy(tty,consolename,strlen(consolename)-1);
sprintf(&tty[strlen(consolename)-1],"%i",flag);
} else { /* use your current vc */
if (isatty(0)) tty = ttyname(0); /* stdin */
Kerry Scott McLeod
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt2921b
Internet: gt2921b@prism.gatech.edu
---559023410-1804928587-1023941137=:17221
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="gpm-1.20.0-socket-vc.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.4.33.0206130005370.17221@acmex.gatech.edu>
Content-Description:
Content-Disposition: attachment; filename="gpm-1.20.0-socket-vc.patch"
ZGlmZiAtdXJOIC4vZ3BtLTEuMjAuMC5vcmlnL3NyYy9saWJsb3cuYyAuL2dw
bS0xLjIwLjAvc3JjL2xpYmxvdy5jDQotLS0gLi9ncG0tMS4yMC4wLm9yaWcv
c3JjL2xpYmxvdy5jCTIwMDItMDItMjMgMTA6NDI6MjMuMDAwMDAwMDAwIC0w
NTAwDQorKysgLi9ncG0tMS4yMC4wL3NyYy9saWJsb3cuYwkyMDAyLTA2LTEz
IDAwOjIwOjA2LjAwMDAwMDAwMCAtMDQwMA0KQEAgLTI0Myw5ICsyNDMsMjUg
QEANCiAgICAgICBjb25uLT52Yz0wOyAgICAgICAgICAgICAgICAgLyogZGVm
YXVsdCBoYW5kbGVyICovDQogICAgICAgaWYgKGZsYWcgPiAwKSB7ICAvKiBm
b3JjZWQgdmMgbnVtYmVyICovDQogICAgICAgICAgY29ubi0+dmM9ZmxhZzsN
Ci0gICAgICAgICBpZigodHR5ID0gbWFsbG9jKHN0cmxlbihjb25zb2xlbmFt
ZSkrR3BtX2NudF9kaWdpdHMoZmxhZykpKSAhPSBOVUxMKQ0KKyAgICAgICAg
IGlmKCh0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zdHJsZW4oY29uc29sZW5hbWUpLTEsIiVzIixjb25z
b2xlbmFtZSk7DQorICAgICAgICAgICoNCisgICAgICAgICAgKiAoZXg6IC9k
ZXYvdHR5MCBiZWNvbWVzIC9kZXYvdHR5KS4NCisgICAgICAgICAgKi8NCisg
ICAgICAgICBtZW1jcHkodHR5LGNvbnNvbGVuYW1lLHN0cmxlbihjb25zb2xl
bmFtZSktMSk7DQogICAgICAgICAgc3ByaW50ZigmdHR5W3N0cmxlbihjb25z
b2xlbmFtZSktMV0sIiVpIixmbGFnKTsNCiAgICAgICB9IGVsc2UgeyAvKiB1
c2UgeW91ciBjdXJyZW50IHZjICovIA0KICAgICAgICAgIGlmIChpc2F0dHko
MCkpIHR0eSA9IHR0eW5hbWUoMCk7ICAgICAgICAgICAgIC8qIHN0ZGluICov
DQo=
---559023410-1804928587-1023941137=:17221--